Search code examples
pythonpython-3.xpbs

Python package cannot be loaded into PBS queue file


The skopt package (https://scikit-optimize.github.io/stable/install.html) was installed on a cluster I use.

When I run the code in python directly in the terminal (i.e., cluster terminal), no problem occurs and the code works as expected.

However when I simply place the command to execute the code in a PBS queue system file (e.g., python3 ./code.py), I cannot load the installed package and I get the following message:

Traceback (most recent call last):
    File "./test.py", line 22, in <module>
       from skopt import gp_minimize
ModuleNotFoundError: No module named 'skopt'

Could someone give me an insight on how to solve the problem?

If I need to provide any more information, let me know.

ps1: the packages is installed on /usr/local/lib/python3.6/site-packages/skopt directory.

ps2: I tried to load export PYTHONPATH=$PYTHONPATH:[$HOME]/.usr/local/lib/python3.6/site-packages/skopt into the PBS file and it didn't work.


Solution

  • The solution was easier than I thought, as the skopt package was in the path "/usr/local/lib/python3.6/site-packages/" just use the command "export PYTHONPATH=$PYTHONPATH:/usr/local/ lib/python3.6/site-packages", before running the code in python

    I was using the "export" command wrongly.