问题描述
我在这里跟着烧瓶教程:
我到了尝试./run.py的地方,我得到:
Traceback(最近一次调用的最后一个):
在< module>文件中的./run.py,第3行。
从应用程序导入应用程序
文件/Users/benjaminclayman/Desktop/microblog/app/__init__.py,第1行,在< module>
from flask import Flask
ImportError:没有名为flask的模块
到:
但他们的解决方案没有帮助。作为参考,我做了一个名为flask的文件夹,其中一个用户提到可能会导致问题。
尝试删除你创建的virtualenv。创建一个新的virtualenv
virtualenv flask
然后
cd flask
让我们激活virtualenv
source bin /激活
现在您应该在命令行的左侧看到(瓶)。
让我们安装烧瓶
pip install flask
$ p $然后创建一个文件hello.py
from flask import Flask
app = Flask(__ name__)
@ app.route(/)
def hello():
返回Hello World!
if __name__ ==__main__:
app.run()
并运行它
python hello.py
I'm following the Flask tutorial here:
http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
I get to the point where I try ./run.py and I get:
Traceback (most recent call last): File "./run.py", line 3, in <module> from app import app File "/Users/benjaminclayman/Desktop/microblog/app/__init__.py", line 1, in <module> from flask import Flask ImportError: No module named flask
This looks similar to:
ImportError: No module named flask
But their solutions aren't helpful. For reference, I do have a folder named flask which one user mentioned may cause issues.
解决方案try deleting the virtualenv you created.create a new virtualenv
virtualenv flask
then
cd flask
let's activate the virtualenv
source bin/activate
now you should see (flask) on the left of the command line.Let's install flask
pip install flask
Then create a file hello.py
from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run()
and run it with
python hello.py
这篇关于Flask ImportError:没有模块命名为Flask的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!