Setting up Python virtualenv
creating a new virtual environment
<source lang='bash'> virtualenv newenv </source>
activating a virtual environment
<source lang='bash'>
source newenv/bin/activate
</source>
(newenv)hjm@ubuntu:~$
installing modules on the virtual environment
Installing modules is the same as usual. The difference is that modules are in /path/to/virtenv/lib
, which may be living somewhere on your home directory. When working from the virtual environment, the default easy_install
will belong to the python version that is currently active. This means that the executable in /path/to/virtenv/bin
are in fact the first in the $PATH
.
<source lang='bash'>
easy_install numpy
</source>
<source lang='bash'>
python setup.py install
</source>
deactivating a virtual environment
<source lang='bash'> deactivate </source>
Make IPython work under virtualenv
source testenv/bin/activate
File "/usr/bin/ipython", line 11
print "Could not start qtconsole. Please install ipython-qtconsole"
^
This can be resolved by adding a soft link with the name
ipython
to the bin
directory in the virtual environment folder.
<source lang='bash'>
ln -s /path/to/virtenv/bin/ipython3 /path/to/virtenv/bin/ipython
</source>