Python Werkzeug AttributeError:&x27;模块';对象没有属性';交互式interpreter';

Python Werkzeug AttributeError:&x27;模块';对象没有属性';交互式interpreter';,python,flask,werkzeug,Python,Flask,Werkzeug,当尝试使用app.run(debug=True)运行代码时,使用Flask(0.8)和Werkzeug(0.8.1)会得到下面描述的错误。使用app.run()时没有错误 错误 Traceback (most recent call last): File "code2.py", line 9, in <module> app.run(debug=True) File "/<snip>/env/lib/python2.7/site-packages/Flask-0

当尝试使用
app.run(debug=True)
运行代码时,使用Flask(0.8)和Werkzeug(0.8.1)会得到下面描述的错误。使用
app.run()时没有错误

错误

Traceback (most recent call last):
File "code2.py", line 9, in <module>
    app.run(debug=True)
File "/<snip>/env/lib/python2.7/site-packages/Flask-0.8-py2.7.egg/flask/app.py", line 703, in run
    run_simple(host, port, self, **options)
File "/<snip>/env/lib/python2.7/site-packages/Werkzeug-0.8.1-py2.7.egg/werkzeug/serving.py", line 587, in run_simple
    from werkzeug.debug import DebuggedApplication
File "/<snip>/env/lib/python2.7/site-packages/Werkzeug-0.8.1-py2.7.egg/werkzeug/debug/__init__.py", line 14, in <module>
    from werkzeug.debug.tbtools import get_current_traceback, render_console_html
File "/<snip>/env/lib/python2.7/site-packages/Werkzeug-0.8.1-py2.7.egg/werkzeug/debug/tbtools.py", line 19, in <module>
    from werkzeug.debug.console import Console
File "/<snip>/env/lib/python2.7/site-packages/Werkzeug-0.8.1-py2.7.egg/werkzeug/debug/console.py", line 144, in <module>
    class _InteractiveConsole(code.InteractiveInterpreter):
AttributeError: 'module' object has no attribute 'InteractiveInterpreter'
为重新创建错误而采取的步骤

$ cd <project directory>
$ . env/bin/activate # Activates virtuanlenv environment (see below for packages)
$ python code.py
到目前为止,我一直试图解决这个问题,但没有起到任何作用(不幸的是)

  • 广泛的谷歌搜索/SO搜索
  • 我的代码大大简化了
  • 删除创建的virtualenv和所有库并通过easy_install重新安装
奇怪的是,昨晚,这个代码运行得很好。今天早上,没有改变任何东西(据我所知),代码无法正常运行


非常感谢你的帮助

问题是您已将模块命名为
code.py
code
是werkzeug使用的内置Python模块


要解决此问题,请将
code.py
重命名为其他名称,并确保删除
code.pyc
文件。

解决问题的方法是使用文件名;不要将python文件名命名为
code.py
main.py
Flask.py
os.py
system.py

相反,你可以使用
code1.py
或其他什么东西。

亚历山大·格雷厄姆·贝尔发明电话时,有三个来自@codeape的未接电话
$ cd <project directory>
$ . env/bin/activate # Activates virtuanlenv environment (see below for packages)
$ python code.py
Flask-0.8-py2.7.egg
Jinja2-2.6-py2.7.egg
pip-1.0.2-py2.7.egg
setuptools-0.6c11-py2.7.egg
Werkzeug-0.8.1-py2.7.egg