Pip默认行为是否与virtualenv冲突? [英] Pip default behavior conflicts with virtualenv?
问题描述
我正在按照本教程 http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world/page/5
当我进入virtualenv flask
命令时,收到以下错误消息:
When I got to virtualenv flask
command, I received this error message:
Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
这很有意义,因为virtualenv的重点是创建一个您可以控制的新环境,并且--user
命令将所有内容都放置在特定位置,从而无法达到分离开发环境的目的.
This makes sense as the point of virtualenv is to create a new environment which you can control, and the --user
command places everything in a specific location, defeating the objective of separation of dev environment.
虽然pip似乎默认为--user
安装,我可以更改此默认行为吗?而且,甚至更好的是,我是否可以一直与Virtualenv玩得开心点?
It seems like pip defaults to --user
installations though, can I change this default behavior? And, even better, can I get pip to play nice with virtualenv at all times?
为了澄清,这是我的终端机的样子.
To clarify, here is what my terminal looks like.
MELCHIOR:miguelgrinberg-microblog megablanc$ virtualenv flask
New python executable in flask/bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/megablanc/Dev...log/flask/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Users/megablanc/Library/Python/2.7/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/Users/megablanc/Library/Python/2.7/lib/python/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/Users/megablanc/Library/Python/2.7/lib/python/site-packages/virtualenv.py", line 1004, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Users/megablanc/Library/Python/2.7/lib/python/site-packages/virtualenv.py", line 969, in install_wheel
'PIP_NO_INDEX': '1'
File "/Users/megablanc/Library/Python/2.7/lib/python/site-packages/virtualenv.py", line 910, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/megablanc/Dev...log/flask/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1
推荐答案
您不需要设置--user
标志.创建virtualenv(virtualenv flask
)后,将其激活:source flask/bin/activate
.您的外壳应类似于(flask) ~>
.
You don't need to set the --user
flag. After you create your virtualenv (virtualenv flask
), activate it: source flask/bin/activate
. Your shell should look something like (flask) ~>
.
一旦激活了virtualenv,您应该可以pip安装软件包而不会出现问题.例如,pip install numpy
.它们将安装在:lib/python2.6/site-packages/
(对于您使用的任何版本的Python)
Once your virtualenv is activated, you should be able to pip install packages without issue. For example, pip install numpy
. They'll be installed in: lib/python2.6/site-packages/
(for whatever version of Python you are using)
这篇关于Pip默认行为是否与virtualenv冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!