我尝试安装烧瓶时尝试了每一个命令行。我已按照http://flask.pocoo.org/docs/installation/
的说明进行操作 sudo easy_install virtualenv
之后:
Searching for virtualenv
Best match: virtualenv 1.11.6
Adding virtualenv 1.11.6 to easy-install.pth file
Installing virtualenv script to /usr/local/bin
Installing virtualenv-2.7 script to /usr/local/bin
Using /usr/local/lib/python2.7/dist-packages
Processing dependencies for virtualenv
Finished processing dependencies for virtualenv
在pip-install flask
之后:
Requirement already satisfied (use --upgrade to upgrade): flask in ./python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): Werkzeug>=0.7 in ./python2.7/dist-packages (from flask)
Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in ./python2.7/dist-packages (from flask)
Requirement already satisfied (use --upgrade to upgrade): itsdangerous>=0.21 in ./python2.7/dist-packages (from flask)
Requirement already satisfied (use --upgrade to upgrade): markupsafe in ./python2.7/dist-packages (from Jinja2>=2.4->flask)
Cleaning up...
但是在. venv/bin/activate
之后:
bash: venv/bin/activate: No such file or directory
我知道如何浏览终端并创建目录。我不确定如何处理此命令和/或激活virtualenv。我找不到这个目录,或者sudo / pip命令可能是针对我的驱动器上没有默认的目录?
我尝试使用flask运行python脚本,当然:
Traceback (most recent call last):
File "testingflask.py", line 1, in <module>
from flask import Flask
ImportError: No module named flask
这是脚本: testingflask.py
from flask import flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
我也试过了apt-get install python-flask
答案 0 :(得分:1)
你做过
吗?$ mkdir myproject
$ cd myproject
$ virtualenv venv
步骤? (显然不是)
在任何情况下,你应该在激活virutualenv之后执行pip install Flask
。否则它将安装在你的基础python安装中。
另外请注意,python区分大小写:
from flask import Flask
app = Flask(__name__)
答案 1 :(得分:0)
你运行virtualenv venv
了吗?我的意思是你的项目中有venv
个文件夹吗?
我猜你错过了这一步!
$ sudo easy_install virtualenv
或sudo easy_install virtualenv
$ mkdir myproject
$ cd myproject
virtualenv venv
我按照这些步骤操作,venv
中应该有一个myproject
目录,$ . venv/bin/activate
命令可以正常工作
答案 2 :(得分:0)
for me :/usr/lib/python2.7/dist-packages
)[记住 root只能执行此操作 强> "import flask"
In [1]: import sys
In [2]: sys.path
Out[2]:
['',
'/usr/bin',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
'/usr/lib/python2.7/dist-packages/IPython/extensions']