python - virtualenv: "cannot import name 'Flask'" -
this question has answer here:
maybe i'm doing wrong, after 1 hour of staring @ code i'm not getting smarter.
my problem virtualenv. set venv2 , venv3 folders in home-directory. installed flask on both of them, alongside other packages.
the problem can't run helloworld-example flask.
from flask import flask app = flask(__name__) @app.route('/') def hello_world(): return 'hello world'
example venv2:
(venv2) #( 7.09.16@14:11 )( dun@arch64l ):~ python /home/dun/venv2/bin/python (venv2) #( 7.09.16@14:12 )( dun@arch64l ):~ python3 /usr/bin/python3 (venv2) #( 7.09.16@14:12 )( dun@arch64l ):~ pip /home/dun/venv2/bin/pip (venv2) #( 7.09.16@14:12 )( dun@arch64l ):~ cd _workspace/py/flask (venv2) #( 7.09.16@14:12 )( dun@arch64l ):~/_workspace/py/flask python2 helloworld.py traceback (most recent call last): file "helloworld.py", line 1, in <module> flask import flask importerror: cannot import name flask (venv2) #( 7.09.16@14:13 )( dun@arch64l ):~/_workspace/py/flask pip list click (6.6) flask (0.11.1) itsdangerous (0.24) jinja2 (2.8) markupsafe (0.23) pip (8.1.2) setuptools (26.1.1) werkzeug (0.11.11) wheel (0.29.0) (venv2) #( 7.09.16@14:13 )( dun@arch64l ):~/_workspace/py/flask python2 helloworld.py traceback (most recent call last): file "helloworld.py", line 1, in <module> flask import flask importerror: cannot import name flask
example venv3:
(venv3) #( 7.09.16@14:10 )( dun@arch64l ):~ python /home/dun/venv3/bin/python (venv3) #( 7.09.16@14:10 )( dun@arch64l ):~ pip /home/dun/venv3/bin/pip (venv3) #( 7.09.16@14:10 )( dun@arch64l ):~ pip list click (6.6) django (1.10.1) flask (0.11.1) itsdangerous (0.24) jinja2 (2.8) markupsafe (0.23) pastedeploy (1.5.2) pip (8.1.2) pyramid (1.7.3) repoze.lru (0.6) setuptools (26.1.1) translationstring (1.3) venusian (1.0) webob (1.6.1) werkzeug (0.11.11) wheel (0.29.0) zope.deprecation (4.1.2) zope.interface (4.3.2) (venv3) #( 7.09.16@14:10 )( dun@arch64l ):~ cd _workspace/py/flask (venv3) #( 7.09.16@14:11 )( dun@arch64l ):~/_workspace/py/flask python helloworld.py traceback (most recent call last): file "helloworld.py", line 1, in <module> flask import flask importerror: cannot import name 'flask'
i don't see file structure, can't sure, if have file called flask.py
in same folder, python import instead of flask module
Comments
Post a Comment