我第一次尝试使用flask和python来创建一个Web应用程序。我在Windows 10上使用Cygwin;出于某种原因,即使我已经使用pip成功安装了烧瓶:
$ pip install flask
Requirement already satisfied (use --upgrade to upgrade): flask in c:\python34\l ib\site-packages
Requirement already satisfied (use --upgrade to upgrade): click>=2.0 in c:\pytho n34\lib\site-packages (from flask)
Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in c:\pyth on34\lib\site-packages (from flask)
Requirement already satisfied (use --upgrade to upgrade): itsdangerous>=0.21 in c:\python34\lib\site-packages (from flask)
Requirement already satisfied (use --upgrade to upgrade): Werkzeug>=0.7 in c:\py thon34\lib\site-packages (from flask)
Requirement already satisfied (use --upgrade to upgrade): MarkupSafe>=0.23 in c: \python34\lib\site-packages (from Jinja2>=2.4->flask)
You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm and.
运行python app.py时仍然出现此错误:
$ python app.py
Traceback (most recent call last):
File "app.py", line 1, in <module>
from flask import Flask
ImportError: No module named flask
任何想法?很抱歉,如果这是一个愚蠢的问题,那就很新了。
答案 0 :(得分:1)
您需要创建一个virtualenv
,然后在其中安装pip。
virtualenv flasktest
下,
cd flasktest
然后,
source bin/activate
最后,
pip install flask
你应该善于运行烧瓶(仅在virtualenv中,它不会在它之外工作。)
答案 1 :(得分:1)
如果您不想使用virtualenv,请尝试使用
python -m pip install --upgrade pip
python -m pip install flask