Skip to content

Instantly share code, notes, and snippets.

@marcoemorais
Created June 18, 2014 22:00
Show Gist options
  • Save marcoemorais/66896078527859006a0d to your computer and use it in GitHub Desktop.
Save marcoemorais/66896078527859006a0d to your computer and use it in GitHub Desktop.
### python-virtualenv-notes ###
Notes from virtualenv documentation on pypi http://pypi.python.org/pypi/virtualenv
o Install
instructions for installing
http://www.virtualenv.org/en/latest/#installation
in case you haven't already install pip
$ sudo apt-get install python-pip
OR
$ easy_install pip
install virtualenv via pip
$ pip install virtualenv
o Running
create a virtualenv by running the virtualenv command
$ virtualenv [path-to-virtualenv-directory]
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
use the *activate* and *deactivate* scripts to enable interpreter from virtualenv
$ source tornado_ve/bin/activate
(tornado_ve)vagrant@precise64:~$ which python
/home/vagrant/tornado_ve/bin/python
(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
(tornado_ve)vagrant@precise64:~$ deactivate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment