Using Flask (0.8) and Werkzeug (0.8.1) when attempting to run code with app.run(debug=True)
I get the below described error. There are no errors when using app.run()
The error
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'
The code (code.py)
from flask import Flask
app = Flask(__name__)
@app.route('/news/')
def news():
pass
if __name__ == '__main__':
app.run(debug=True)
Steps taken to recreate the error
$ cd <project directory>
$ . env/bin/activate # Activates virtuanlenv environment (see below for packages)
$ python code.py
Contents of my env/lib/python2.7/site-packages (versions of various library used) via virtualenv
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
Things I have tried to solve this problem so far, that have not helped (unfortunately)
The strange thing here is that last night, this code worked fine. This morning, without changing anything (that I'm aware of) the code failed to properly run.
Thanks very much for your help!
The problem is that you have named your module code.py
. code
is a built in Python module that werkzeug uses.
To fix the problem, rename your code.py
to something else, and make sure you delete the code.pyc
file.