Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
habrok:examples:vscode_python [2025/05/27 09:11] – created fokke | habrok:examples:vscode_python [2025/05/27 09:17] (current) – fokke | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== Using Python modules in VScode ==== | ===== Using Python modules in VScode ==== | ||
+ | |||
+ | VScode is available on the cluster in the Web portal or through an ssh connection from your local VScode software. See [[../ | ||
When using VScode to develop your software on the cluster it is best to make use of virtual environments. | When using VScode to develop your software on the cluster it is best to make use of virtual environments. | ||
Line 7: | Line 9: | ||
==== Creating the virtual environment ==== | ==== Creating the virtual environment ==== | ||
- | 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: | + | 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 | module spider Python | ||
Line 16: | Line 18: | ||
module load Python/ | module load Python/ | ||
</ | </ | ||
+ | |||
+ | Create and activate a virtual environment in the expected '' | ||
+ | < | ||
+ | python -m venv .venv | ||
+ | source .venv/ | ||
+ | </ | ||
+ | |||
+ | 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 " | ||
+ | < | ||
+ | pip install matplotlib | ||
+ | </ | ||
+ | |||