Difference between revisions of "Using virtualenv"

From mn/bio/cees-bioinf
Jump to: navigation, search
(Created page with "virtualenv is a tool to create isolated Python environments. See [https://virtualenv.pypa.io/en/latest/index.html https://virtualenv.pypa.io/en/latest/index.html] === Setting...")
 
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
=== Setting up virtualenv on the cod-nodes/abel ===
 
=== Setting up virtualenv on the cod-nodes/abel ===
 
+
<pre>module load python2
module load python2 virtualenv my_python_dir
+
virtualenv my_python_dir</pre>
 
 
 
will create locally a python tree.
 
will create locally a python tree.
  
 
Then you can run
 
Then you can run
 +
<pre>cd my_python_dir
 +
./bin/activate</pre>
 +
And you're ready to go.
  
cd my_python_dir ./bin/activate
+
This is a fix necessary for abel and the cod nodes, normally not necessary:
 
+
<pre>unset PYTHONPATH</pre>
And you're ready to go. Thsi will help to set paths properly:
+
Deactivating the environment
 
+
<pre>deactivate</pre>
export PYTHONPATH=$PYTHONPATH:$PWD/lib/python2.7/site-packages/
+
==== Using an existing virtual env ====
 
+
<pre>cd my_python_dir
==== When using setup.py scripts ====
+
./bin/activate</pre>
 
+
==== Installing modules in your virtualenc ====
python setup.py install --prefix=/path/to/my_python_dir
 
 
 
<br/>Then to install a package not already in the python2 module do:
 
 
 
pip install package_name
 
  
this package (if found by pip) will be installed locally and reachable via the paths previously set up.
+
Activate and then run
 +
<pre>pip install module_name</pre>

Latest revision as of 13:22, 16 June 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.

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

unset PYTHONPATH

Deactivating the environment

deactivate

Using an existing virtual env

cd my_python_dir
./bin/activate

Installing modules in your virtualenc

Activate and then run

pip install module_name