Unable to use packages in conda environment in compute nodes

Hello there,
I’ve been having this problem just recently that used to work fine. I used conda to create my preferred environment that contain the required packages for my code. However, this time the system reported that all the packages required could not be found. I use the “conda list” command and found the packages I installed, but python seemed not able to find them. Does anyone know what’s going on?


@jiangxu It looks like the wrong version of Python is being used, the one in the base environment instead of your environment. Try reactivating your environment, or try activating the base environment first and then your environment. And you might check your PATH variable to see if anything is off.

Hello dstrong,
I can use my conda environment correctly at the home node but can’t do it at the computation node. So what is the difference?
Thank you,
Jiang

Hello dstrong,
I think I found the cause and the solution. I tried to deactivate and reactivate the environment, the program works. The following posts described the problem and the principle. Thank you.
https://github.com/conda/conda/issues/9392
Jiang

The ~/.bashrc, which sets up conda in your shell, is not sourced for Slurm jobs. So you could either run source ~/.bashrc or just run eval "$(conda shell.bash hook)".

Thanks dstrong, thank you for the suggestion. I will try that.
Best,
Jiang

I am now experiencing this error. It appears to be related to the recent removal of anaconda3. My slurm script now looks like this. What needs to be changed?

module purge
module load conda
eval "$(conda shell.bash hook)"
conda activate my-env
which python
conda env config vars list
python main.py

The console outputs

/spack/conda/miniconda3/4.12.0/bin/python
LD_LIBRARY_PATH = /home1/haomingl/.conda/envs/my-env/lib
Traceback (most recent call last):
...
ModuleNotFoundError: No module named 'xxx'

Edit: Issue resolved after doing this:

cd /spack/conda/miniconda3/4.12.0/bin
./conda init bash