Python virtual environment

From ScientificComputing
Revision as of 13:12, 2 June 2021 by Jarunanp (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This example shows how to create a Python virtual environment. First, switch to the new software stack

$ env2lmod

or, set your default software stack to the new software stack

$ set_software_stack.sh new

Load a Python module

$ module load gcc/6.3.0 python/3.8.5

Create a Python virtual environment

$ python -m venv --system-site-packages myenv

Activate the virtual environment

$ source myenv/bin/activate

Check the python packages included in this environment

(myenv)$ pip list

You can install new packages inside this environment

(myenv)$ pip install --upgrade pip

Deactivate the Python virtual environment

(myenv)$ deactivate