This is an old revision of the document!


When using VScode to develop your software on the cluster it is best to make use of virtual environments. These virtual environments work in the same way as other virtual environments outside of VScode. The best way to handle these is to create the virtual environment in a place where VScode expects it. This is in the .venv` folder within your project.

Setting up the virtual environment is best done within the Terminal window of VScode. The first step is to load a Python module with the version that you want to use. You can find the available versions using:

module spider Python

After selecting a version from the list you can load it using:

module load Python/3.11.5-GCCcore-13.2.0

Create and activate a virtual environment in the expected .venv location.

python -m venv .venv
source .venv/bin/activate

You will probably get a pop-up from VScode that it noticed the new .venv. It will offer to select it for this project. You can say yes, to switch to this environment.

You can also select the Python version from the virtual environment using the Python version selection box at the bottom right of the VScode window.

After this you can proceed to install packages into the virtual environment using pip in the “Terminal” window, e.g.:

pip install matplotlib