Created
September 5, 2014 16:50
-
-
Save marcoemorais/c2e4f99603de6547f284 to your computer and use it in GitHub Desktop.
python virtualenv notes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### python-virtualenv-notes ### | |
Notes from virtualenv documentation on pypi http://pypi.python.org/pypi/virtualenv | |
o Install | |
o instructions for installing | |
http://www.virtualenv.org/en/latest/#installation | |
o in case you haven't already install pip | |
$ sudo apt-get install python-pip | |
OR | |
$ sudo easy_install pip | |
o install virtualenv via pip | |
$ pip install virtualenv | |
o Running | |
o create a virtualenv by running the virtualenv command | |
$ virtualenv [path-to-virtualenv-directory] | |
o virtualenv adds a python interpreter to the 'bin' subidirectory | |
this interpreter is configured to prepend the virtualenv directory to the PYTHONPATH | |
$ ./ve1/bin/python -c "import sys; print('\n'.join(sys.path))" | |
/vagrant/ve1/local/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg | |
/vagrant/ve1/local/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg | |
/vagrant/ve1/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg | |
... | |
/usr/lib/python2.7 | |
o use the *activate* and *deactivate* scripts to enable interpreter from virtualenv | |
$ source tornado_ve/bin/activate | |
# confirm interpreter from virtualenv is being used | |
(tornado_ve)vagrant@precise64:~$ which python | |
/home/vagrant/tornado_ve/bin/python | |
# pip installs into virtualenv, not system path | |
(tornado_ve)vagrant@precise64:~$ pip install tornado | |
... | |
(tornado_ve)vagrant@precise64:~$ pip freeze | |
argparse==1.2.1 | |
tornado==2.4.1 | |
wsgiref==0.1.2 | |
# deactivate the virtualenv | |
(tornado_ve)vagrant@precise64:~$ deactivate | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment