WebFaction
Community site: login faq

I'm trying to get virtualenv working:

  • I first tried pip-2.7 install virtualenv, which worked.
  • I then tried to create a virtualenv and got some error relating to setuptools. So I tried upgrading pip and easy_install: I tried several things, which I don't remember at this time, and in short virtualenv works now although I somehow broke pip-2.7. But if I just use pip or pip2.7 things seem to work fine (I'm not even sure what the difference is between all those? or if I broke something important that I'm not aware of).
  • The problem now is that if I navigate to my virtualenv and then run source bin/activate, and then run pip freeze, it shows all the packages from my home/lib/python2.7 site-packages. This is even after specifying --no-site-packages when creating the virtualenv.
  • which python2.7 shows ~/temp/nw/test/bin/python2.7 (temp/nw/test is my virtualenv folder)

With all the mess around the installation I don't know if I have it setup correctly? Why doesn't my virtualenv seem to be isolated as a virtual environment?

asked 31 Jan '14, 13:19

rsp's gravatar image

rsp
14511
accept rate: 0%


The difference in pip is pip-2.7 ? version 1.4 and pip2.7 ? version 1.5.

Because of the global sitecustomize.py on file at /usr/local/pythonX.Y/sitecustomize.py, the packages inside of your $HOME/lib/pythonX.Y directory are added to your python path, even inside of a virtualenv.

In some cases this is what you want and is convenient. Other times, you do not want a particular virtualenv to use your home-installed packages. If that's the case, then create an empty sitecustomize.py file inside of the virtualenv itself, which will act to override the global one and prevent the home-installed packages from being added to your path:

virtualenv foo
touch foo/lib/pythonX.Y/sitecustomize.py
source foo/bin/activate
pip freeze
permanent link

answered 31 Jan '14, 13:44

timg's gravatar image

timg ♦♦
1.3k4
accept rate: 30%

Thank you very much! Your post was very helpful in successfully upgrading my own WebFaction Django projects to work under virtualenv. I wrote up my experience here: http://stationinthemetro.com/2015/07/31/upgrading-django-to-use-virtualenv-on-webfaction

(01 Aug '15, 02:05) bobtiki bobtiki's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×877
×50
×47

question asked: 31 Jan '14, 13:19

question was seen: 4,071 times

last updated: 01 Aug '15, 02:05

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2016 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM