pyslurm
pyslurm copied to clipboard
pyslurm import error
Details
- Slurm Version: 20.8.11
- Python Version: 3.9.7
- Cython Version: 0.29.24
- PySlurm Branch: main
- Linux Distribution: Ubuntu 18.04
Issue
After successfully building (I think)...
...and installing pyslurm (I think)...
when I attempt to import pyslurm I get this error:
Also, when I attempt the pyslurm install from the 20.11.8 branch or tag I get the following version error:
pyslurm 20.11.8 install and run works fine for me. I think the "no module named pyslurm.pyslurm" error is simply due to cwd in pyslurm (which contains a folder pyslurm).
python3 -c 'import pyslurm; print(pyslurm.__version__)'
20.11.8.0
cd pyslurm-20.11.8-1/
python3 -c 'import pyslurm; print(pyslurm.__version__)'
ModuleNotFoundError: No module named 'pyslurm.pyslurm'
As @schluenz hinted, the original import error stems from the fact that python, by default, always searches for modules/packages inside the current working directory first (see here). So if you do import pyslurm
from the top-directory in the repo, you will receive this import error, because there is actually no pyslurm.py
in the pyslurm
directory
The import would probably work for a ordinary python project, but since pyslurm consists of almost only *.pyx
files that have to be compiled first, it won't work. It would work with an editable install, or, since python 3.11 there is a new command-line flag -P that prevents prepending the cwd.
So importing the pyslurm library will work from anywhere but the top-directory in the git repo