-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
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
flaskr project (in dev docs and on github) needs to use relative import in __init__.py for Python 3 #2051
Comments
Good catch, this is my mistake. That line should be |
Yes, that also fixes it. |
Thanks for the quick fix to the project itself. You may want to fix the documentation on this page, too: http://flask.pocoo.org/docs/dev/tutorial/packaging/#tutorial-packaging |
That should eventually update automatically. |
@untitaker Are there tools available to link parts of a code example to documentation? That would be quite nice. |
What do you mean? |
Are you talking about the examples directory in the repo, or inline code examples? |
I found this error as well. This is my (working)
|
Currently, while following the dev docs or cloning the existing flaskr project on GitHub, it will not run in a Python 3 virtualenv. The error when running the cloned flaskr application is:
Traceback (most recent call last): File "/home/todd/flaskr/flask/examples/flaskr/env/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise raise value File "/home/todd/flaskr/flask/examples/flaskr/flaskr/__init__.py", line 1, in <module> from flaskr import app ImportError: cannot import name 'app'
This is the same error when following the docs to recreate the flaskr application. By modifying
flaskr/__init__.py
to include a relative import when using a Python 3 virtualenv, everything works fine.That is, in
flaskr/__init__.py
, change:from flaskr import app
to:
from .flaskr import app
(note the period)
At this point, I am still not comfortable contributing, nor do I know if this is the correct solution or if this has any implications for Python 2. Hence the issue, hoping someone else can confirm this is correct, or provide a better solution.
The text was updated successfully, but these errors were encountered: