我正在尝试按照以下教程http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world#commentform
我似乎非常迷茫。首先从我的理解。运行命令'python virtualenv.py flask'在文件夹'flask'中创建一个虚拟python环境。这是对的吗?其次,这是不是意味着如果我cd到这个文件夹,然后运行'pip install flask'它应该将flask安装到该文件夹?当我运行任何这些pip安装命令时,我的终端充满了疯狂的疯狂,我不明白。
Benjamins-MacBook:flask test$ pip install flask==0.9
Downloading/unpacking flask==0.9
Downloading Flask-0.9.tar.gz (481kB): 481kB downloaded
Running setup.py egg_info for package flask
warning: no files found matching '*' under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'docs'
warning: no previously-included files matching '*.pyo' found under directory 'docs'
warning: no previously-included files matching '*.pyc' found under directory 'tests'
warning: no previously-included files matching '*.pyo' found under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'examples'
warning: no previously-included files matching '*.pyo' found under directory 'examples'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'docs/_themes/.git'
Downloading/unpacking Werkzeug>=0.7 (from flask==0.9)
Downloading Werkzeug-0.9.4.tar.gz (1.1MB): 1.1MB downloaded
Running setup.py egg_info for package Werkzeug
warning: no files found matching '*' under directory 'werkzeug/debug/templates'
warning: no files found matching '*' under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'docs'
warning: no previously-included files matching '*.pyo' found under directory 'docs'
warning: no previously-included files matching '*.pyc' found under directory 'tests'
warning: no previously-included files matching '*.pyo' found under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'examples'
warning: no previously-included files matching '*.pyo' found under directory 'examples'
no previously-included directories found matching 'docs/_build'
Downloading/unpacking Jinja2>=2.4 (from flask==0.9)
Downloading Jinja2-2.7.1.tar.gz (377kB): 377kB downloaded
Running setup.py egg_info for package Jinja2
warning: no files found matching '*' under directory 'custom_fixers'
warning: no previously-included files matching '*' found under directory 'docs/_build'
warning: no previously-included files matching '*.pyc' found under directory 'jinja2'
warning: no previously-included files matching '*.pyc' found under directory 'docs'
warning: no previously-included files matching '*.pyo' found under directory 'jinja2'
warning: no previously-included files matching '*.pyo' found under directory 'docs'
Downloading/unpacking markupsafe (from Jinja2>=2.4->flask==0.9)
Downloading MarkupSafe-0.18.tar.gz
Running setup.py egg_info for package markupsafe
Installing collected packages: flask, Werkzeug, Jinja2, markupsafe
Running setup.py install for flask
warning: no files found matching '*' under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'docs'
warning: no previously-included files matching '*.pyo' found under directory 'docs'
warning: no previously-included files matching '*.pyc' found under directory 'tests'
warning: no previously-included files matching '*.pyo' found under directory 'tests'
warning: no previously-included files matching '*.pyc' found under directory 'examples'
warning: no previously-included files matching '*.pyo' found under directory 'examples'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'docs/_themes/.git'
error: could not create '/Library/Python/2.7/site-packages/flask': Permission denied
Complete output from command /usr/bin/python -c "import setuptools;__file__='/private/var/folders/9l/6fgb2st97cs2b2jkj7g4bs5m0000gp/T/pip_build_test/flask/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/9l/6fgb2st97cs2b2jkj7g4bs5m0000gp/T/pip-PbWDVv-record/install-record.txt --single-version-externally-managed:
知道我做错了吗?
答案 0 :(得分:7)
您需要先在新的flask文件夹中找到bin/activate
脚本来激活virtualenv。
如果您正在运行bash
(最有可能),请运行:
cd new/flask/directory
. bin/activate
pip install ...
如果您想退出virtualenv,可以退出终端标签页,或运行:
deactivate
请注意,当您激活virtualenv时,它仅在您所在的一个终端选项卡中处于活动状态。
如果您没有先运行该命令,那么pip
将尝试安装到您的系统目录中,从而提供您所看到的权限错误。
答案 1 :(得分:0)
virtualenv必须在创建之后激活。
转到刚刚创建的virtualenv目录,并从bin目录中获取激活脚本:
$ source flask/bin/activate
另外,请看一下第一个答案:Warnings and errors after trying to install Flask 0.9
答案 2 :(得分:0)
错误说:error: could not create '/Library/Python/2.7/site-packages/flask': Permission denied
表示您需要root权限才能安装flask。试试sudo pip install flask==0.9