Python 使用Virtualenv安装烧瓶

Python 使用Virtualenv安装烧瓶,python,flask,virtualenv,pip,Python,Flask,Virtualenv,Pip,我正试图遵循以下教程 我好像迷路了。首先,根据我的理解。运行命令“pythonvirtualenv.pyflask”在文件夹“flask”中创建一个虚拟python环境。这是正确的吗 第二,这是否意味着如果我将cd刻录到此文件夹,然后运行“pip install flask”,它应该将flask安装到该文件夹?当我运行这些pip install命令时,我的终端充满了我不理解的疯狂 Benjamins-MacBook:flask test$ pip install flask==0.9 Downl

我正试图遵循以下教程

我好像迷路了。首先,根据我的理解。运行命令“pythonvirtualenv.pyflask”在文件夹“flask”中创建一个虚拟python环境。这是正确的吗

第二,这是否意味着如果我将cd刻录到此文件夹,然后运行“pip install flask”,它应该将flask安装到该文件夹?当我运行这些pip install命令时,我的终端充满了我不理解的疯狂

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:

你知道我做错了什么吗?

你需要先在新的flask文件夹中找到
bin/activate
脚本来激活virtualenv

如果正在运行
bash
(很可能),则运行:

cd new/flask/directory
. bin/activate
pip install ...
当您想退出virtualenv时,可以退出终端选项卡,或运行:

deactivate
请注意,激活virtualenv时,它仅在您所在的一个终端选项卡中处于活动状态


如果您不先运行该命令,则
pip
将尝试安装到您的系统目录中,从而给出您看到的权限错误。

必须在创建virtualenv之前和之后激活它

更改为刚刚创建的virtualenv目录,并从bin目录中获取激活脚本的源代码:

$ source flask/bin/activate

另外,请看这里的第一个答案:

错误说明:
错误:无法创建“/Library/Python/2.7/site packages/flask”:权限被拒绝
,这意味着您需要根权限才能安装flask。请尝试
sudo pip install flask==0.9

谢谢,但是。。我如何找到垃圾箱/激活垃圾箱?嘿。。你能进一步解释一下吗?我是个初学者,真的不知道那意味着什么。