Sunday, March 29, 2015

Python virtualenv - Facts

Following the best practices of industry, just installed Python Virtual Environments in Mavericks. But every time I try to 'activate', which should have changed the command prompt, nothing happens... just nothing.

Searched all over the web but nobody seems to have the issue I am having... must be doing something foolish and I was...

Fact-1
You have to activate using 'source' command. So basically you have to type
Virtualenvs% source .bin/activate

and voila...

Being curious when looked inside 'activate' found that its just a simple shell script which sets few environment variables like VIRTUAL_ENV and PATH so that we don't have to.


Next thing that kept me confused for few hours is, what the heck is happening when I am installing new packages using 'pip' from inside my virtual env. Can't find any new folders created in 'include' or 'lib'... no new binaries in bin...

where are all those downloaded files disappearing into?

Fact-2
Anything you install inside a virtual environment will get stored inside the python site-packages folder which is under the lib folder. In my case it was
lib/python2.7/site-packages


and the learning continues...