...
Command | Meaning | ||
---|---|---|---|
| shows the versions of Python installed on O2 (requires | ||
| loads an individual module (substitute | ||
| unloads an individual module version | ||
| shows the current version of Python loaded (use | ||
| shows what packages are installed for currently loaded Python module |
Note that in order for You can use module avail python
to give any output, you must have gcc/6.2.0
loaded into your environment. Alternately, you can use module spider python
to circumvent this, but you will still need gcc/6.2.0
loaded in order to load any python modules that are installed.
Setting Up a Virtual Environment
Setup
...
as an alternative to module spider python
, but avail
will only work if you have some gcc
module loaded (avail
only searches exposed hierarchies, where spider
searches the entire module list).
Setting Up a Virtual Environment
Setup
Code Block |
---|
mfk8@login01:~$ module load gcc/9.2.0 mfk8@login01:~$ module avail python mfk8@login01:~$ module load gcc/6.2.0 mfk8@login01:~$ module avail python mfk8@login01:~$ module load python/3.78.412 # or whichever version you'd like here mfk8@login01:~$ which virtualenv mfk8@login01:~$ virtualenv nameyourenvhere # Please read on before executing this command as-is |
...
The --system-site-packages
flag will allow your virtual environment to inherit all existing installed packages in that Python distribution (which means you don't need to install your own numpy or scipy). On O2, we have purposely kept the list of installed python modules as light as possible so that the user is afforded the maximum amount of flexibility to install the versions they need. You can create as many virtual environments as you need.
Note |
---|
Note that for the |
Code Block |
Be aware that if you have other tools or configurations in your environment that leverage the use of |
To uninstall a virtual environment, simply rm -rf
the folder containing the directory:
...
Note |
---|
Package mismatch errors with environments that use |
The pip install --user
flag
You may come across this flag in the installation instructions for a python package. This option is NOT RECOMMENDED on O2. Using this flag results in your python package installing to $HOME/.local
. This location does not change if you switch between python versions, so if there is any possibility that you need to use multiple python versions for your work (e.g., for different projects), your $HOME/.local
directory can quickly fill up with packages that were installed against mismatching python versions, which can cause incompatibility issues later on. This behavior is why RC recommends usage of virtual environments to keep package lists completely independent of each other.
Relatedly, if you are experiencing execution errors with mismatched package versions, the first step to troubleshooting is to delete the $HOME/.local
directory. If the error persists after taking this step, please contact rchelp@hms.harvard.edu for further assistance.