Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask debug not working under Anaconda

I'm working in a standard development environment with Flask and am having trouble getting the debug to work.

Just using the standard Hello World, with an error like so:

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    err
    return "Hello World!"

if __name__ == "__main__":
    app.run(debug=True)

My application breaks, but there is no dynamic debugging and I get the following error message:

If you enable JavaScript you can also use additional features such as code 
execution (if the evalex feature is enabled), automatic pasting of the 
exceptions and much more.

I have JavaScript enabled, and don't know why I'm receiving this error. Any ideas?

EDIT

I found this similar post here. It appears that Flask can't find a few files.

127.0.0.1 - - [23/Feb/2014 22:04:37] "GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 404 -

I am using Anaconda and have removed and reinstalled both Flask and Werzeug, but am still having the issue.

like image 521
dvreed77 Avatar asked Feb 24 '14 02:02

dvreed77


Video Answer


2 Answers

You can also uninstall the conda packages

conda remove flask
conda remove werkzeug

Then just pip install both of those

pip install flask
pip install werkzeug

That worked for me using conda 3.4.2

like image 112
Gourneau Avatar answered Sep 19 '22 21:09

Gourneau


The above comment by dirn Feb 24 at 3:35 is correct. However, with anaconda, uninstalling and reinstalling packages does not help. Here is a hack that got mine to work...

The werkzeug/debug directory on my anaconda installation is missing a directory called shared. I have a non-anaconda installation of flask (using macports in my case). I simply copied that directory from my macports installation to the anaconda installation. The command for this with full path names that I used for my flasky conda virtual environment was:

cp -r /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/werkzeug/debug/shared  ~/anaconda/envs/flasky/lib/python2.7/site-packages/werkzeug/debug 

You need to do this separately for each conda virtual environment. Your path names may vary. Also, you should probably ensure that the non-anaconda installation is the same version of werkzeug.

like image 27
user3549604 Avatar answered Sep 20 '22 21:09

user3549604