New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flask fails to start with use_reloader=True when using absolute import #1246
Comments
Please check for stray |
Unfortunatelly, running |
Is
|
@pgk: With your command it works. I searched my environment for
Is there something wrong with my configuration? Or there is a conflict between some libraries? |
Could you print sys.path in hello.py without the suggested command? |
Here you are:
Edit: When running it with the suggested command, the first (empty) entry is replaced by the actual working directory. |
I suppose that when running with |
Just wanted to note that I'm having the exact same issue, I switched my project structure around so I wouldn't have to add to PYTHONPATH, but it looks like I'm going to have to if I want to use reloader ? |
Same issue here, app fails to load absolute import when using debug=True. Debug=False works fine. |
The current solution is to avoid running your app via The issue I linked above contains all the details and why this is an unfixable problem AFAIK On 18 June 2015 11:59:41 CEST, "Piotrek Szymański" notifications@github.com wrote:
|
@untitaker better solution is to run the app with
just as @pgk suggested. Actually, this is the only way that works for me. |
That actually works, Thanks! |
I personally fixed this using the following in my equivalent of # Workaround for the werkzeug reloader removing the current directory from the
# path. It's nasty, but it works! Inspired by:
# https://github.com/mitsuhiko/flask/issues/1246
os.environ['PYTHONPATH'] = os.getcwd() Just do that before you call |
note, however, that due to an issue with Werkzeug's reloader, debug mode still requires a separate script: pallets/flask#1246
We now encourage you to install your project in editable mode during development. |
I'm using Flask v0.10.1 and I have the following project structure:
The hello.py file is:
and the config.py is simply
When I run
api.py
withuse_reloader=False
(python -m test.api.hello
) the server starts correctly. If I run it withuse_reloader=True
(python -m test.api.hello --reloader
) it fails with:The text was updated successfully, but these errors were encountered: