Difference between revisions of "Using virtualenv"

From mn/bio/cees-bioinf
Jump to: navigation, search
Line 9: Line 9:
 
<pre>cd my_python_dir
 
<pre>cd my_python_dir
 
./bin/activate</pre>
 
./bin/activate</pre>
And you're ready to go.<br/>This will help to set paths properly:
+
And you're ready to go. Deactivating the environment
<pre>export PYTHONPATH=$PYTHONPATH:$PWD/lib/python2.7/site-packages/</pre>
+
<pre>deactivate</pre>
==== When using setup.py scripts ====
+
This is a fix necessary for abel and the cod nodes, normally not necessary:
<pre>python setup.py install --prefix=/path/to/my_python_dir</pre>
+
<pre>unset PYTHONPATH</pre>
Then to install a package not already in the python2 module do:
+
==== Using an existing virtual env ====
<pre>pip install package_name</pre>
+
<pre>cd my_python_dir
This package (if found by pip) will be installed locally and reachable via the paths previously set up.
+
./bin/activate</pre>

Revision as of 13:54, 28 April 2015

virtualenv is a tool to create isolated Python environments. See https://virtualenv.pypa.io/en/latest/index.html

Setting up virtualenv on the cod-nodes/abel

module load python2
virtualenv my_python_dir

will create locally a python tree.

Then you can run

cd my_python_dir
./bin/activate

And you're ready to go. Deactivating the environment

deactivate

This is a fix necessary for abel and the cod nodes, normally not necessary:

unset PYTHONPATH

Using an existing virtual env

cd my_python_dir
./bin/activate