简体   繁体   English

在Virtualenv中全局安装Pip

[英]Pip installing globally in virtualenv

I'm having trouble getting pip to work in a virtualenv, whenever I run the following commands with the following output: 每当我运行具有以下输出的以下命令时,我就无法使pip在virtualenv中工作:

$ virtualenv --no-site-packages foo
  New python executable in foo/bin/python
  Installing setuptools, pip...done.
$ cd foo/
$ source bin/activate
$ pip freeze
  Django==1.6.1
  PIL==1.1.7
  beautifulsoup4==4.3.2
  distribute==0.6.34
  dj-database-url==0.2.2
  dj-static==0.0.5
  django-toolbelt==0.0.1
  gunicorn==18.0
  numpy==1.7.1
  psycopg2==2.5.2
  pystache==0.5.3
  requests==2.2.1
  scipy==0.12.0
  static==1.0.2
  stevedore==0.14.1
  virtualenv==1.11.4
  virtualenv-clone==0.2.4
  virtualenvwrapper==4.2
  wsgiref==0.1.2

And I do have the correct shebang: #!/Users/username/Programming/Django_Projects/foo/bin/python 而且我确实有正确的shebang: #!/Users/username/Programming/Django_Projects/foo/bin/python

Here is what i get when I run which pip : /Users/username/Programming/Django_Projects/foo/bin/pip 这是我运行which pip时得到的which pip/Users/username/Programming/Django_Projects/foo/bin/pip

And when I try to install Django: Requirement already satisfied (use --upgrade to upgrade): Django in /usr/local/lib/python2.7/site-packages Cleaning up... 当我尝试安装Django时: Requirement already satisfied (use --upgrade to upgrade): Django in /usr/local/lib/python2.7/site-packages Cleaning up...

I am not pretty sure, but I think when you're calling the --no-site-packages option basically you are inheriting the modules installed in the system, I did the same as you and I could not find the site-packages folder (where your modules should be included when installed) on neither of my folders. 我不太确定,但是我认为当您调用--no-site-packages选项时,基本上是在继承系统中安装的模块,我所做的与您相同,并且找不到site-packages文件夹(在安装时应包括您的模块的位置)在我的两个文件夹中都没有。

My recommendation is to avoid no-site-packages option if you want a "clean slate" installation of PIP. 我的建议是,如果您希望“干净的” PIP安装,请避免使用no-site-packages选项。

I was having a similar issue. 我有一个类似的问题。 I ended up setting the following environment variables, and it's been smooth ever since. 我最终设置了以下环境变量,从那以后一直很顺利。

PIP_REQUIRE_VIRTUALENV=true
PIP_RESPECT_VIRTUALENV=true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM