PySlurm / pyslurm

Python Interface to Slurm
https://pyslurm.github.io
GNU General Public License v2.0
476 stars 117 forks source link

pyslurm import error #226

Closed hokiegeek2 closed 1 year ago

hokiegeek2 commented 2 years ago

Details

Issue

After successfully building (I think)...

image

...and installing pyslurm (I think)...

image

when I attempt to import pyslurm I get this error:

image

hokiegeek2 commented 2 years ago

Also, when I attempt the pyslurm install from the 20.11.8 branch or tag I get the following version error:

image

schluenz commented 2 years ago

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'
tazend commented 1 year ago

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