7

I am trying to develop Python code on a remote cluster. If I were doing this directly on the cluster, I would have to load an Anaconda Lmod module before I could access any of my conda environments:

module load Anaconda3/2020.11

As a quality of life improvement, I would like to use VSCode with the Remote-SSH extension to work on the cluster. However, I cannot seem to load the module that I need in order to select my conda environment as the Python interpreter. Running the module load XX command in the VSCode terminal does not seem to apply the settings when I run a Python script.

Is there a way for me to load the module using VSCode after I connect to the remote machine so that I can access my conda environment and run my code?

book_kees
  • 307
  • 1
  • 9

2 Answers2

2

I had the same problem and solved it by loading the lmod modules when the vscode server starts.

The verified answer in this issue brought me towards the solution.

You can just put the module load Anaconda3/2020.11 command in your .profile file in your home directory. If none exists on the cluster you can just create one.

hboehmer
  • 21
  • 5
  • 1
    Beware that loading modules in your .profile or .bashrc is succeptible to break some other stuff that the cluster might also be used for. From experience ThinLinc is one such thing. It is possible to circumvent this if you figure some logic to only do module load in the right circumstances. – VRehnberg Jan 18 '23 at 07:23
0

At least for Jupyter Notebooks there is a solution now:

Open a terminal within your remote session, do

module load Anaconda3/2020.11
conda activate myenv
jupyter notebook --NotebookApp.allow_origin='*' --NotebookApp.ip='0.0.0.0' --no-browser

then copy the url, click select kernel > existing jupyter server > enter url, select the kernel and go.

Note that pylance still does not work in this setup.

More infos in the docs.

rolly
  • 145
  • 9