Monday, August 6, 2012

python virtualenv

There are already lots of articles telling us why we need virtualenv to provide a separate environment(sandbox), such as different projects may depends on different libraries, or you don't have the write permission to the /path/to/python/site-packages directory.

I'm using pip to install virtualenv, it's pretty easy,
pip install virutalenv

then create an sandbox for my project, with the option --no-site-packages to isolate from main site-packages,
virutalenv --no-site-packages social-map 

finally, i cloned my project directly into social-map. To active this environment,
source social-map/bin/active

if you want to deactive this environment, just type deactive. I don't know how to deactive the envrionment before, what i did was exit the terminator, then open a new one, very silly...

we can check the settings as `which python` etc. If you check the active script in ~/your/env/bin/, you can find this, virtual will change your path, and put the virtualenv's path at the beginning of the path, it will change your terminer's PS1 also.
VIRTUAL_ENV="/Users/pengphy/Codes/virtualenvs/social-map"
PATH="$VIRTUAL_ENV/bin:$PATH"

http://www.doughellmann.com/articles/pythonmagazine/completely-different/2008-02-ipython-and-virtualenv/index.html 


http://mitchfournier.com/2010/06/25/getting-started-with-virtualenv-isolated-python-environments/

No comments:

Post a Comment