简体   繁体   中英

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:

$ 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

Here is what i get when I run 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...

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.

My recommendation is to avoid no-site-packages option if you want a "clean slate" installation of PIP.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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