Cannot import user-made python package within certain folders?

Hi, I’ve been having a weird issue regarding a python package I am developing. I have installed the package using “python setup.py develop --prefix=PROJECT_FOLDER” on the Discovery cluster. When I open a python terminal in this folder, I am able to import the package just fine. In a folder within PROJECT_FOLDER, I am also able to import the package. However, if I go one level deeper, I get a ModuleNotFoundError.

I have tried “python setup.py install --prefix=PROJECT_FOLDER” and I have tried installing in my home directory. None of these seem to solve the issue. My PYTHONPATH includes the site-packages folder where the above command installs the package. I have not had this issue with normal python packages that I have also installed (e.g., astropy). I also do not have this issue on my personal machine.

Hi,

If you installed your package with python setup.py install --prefix=$PROJECT_FOLDER, you can try adding $PROJECT_FOLDER/lib/python/a.b/site-packages to your $PYTHONPATH (where a=major version number and b=minor version, ie 3.11).

Best,
Cesar

I just reread your initial message and saw that you have already tried my suggestion. In that case, I would suggest checking to make sure the package on your personal machine is identical to the one you have on the Discovery cluster.

If you don’t mind, you could also send me a copy of your package so I can try it.
-Cesar

Hi Cesar,

Thanks for responding. I went to the CARC office hours yesterday and we managed to get this fixed, although I don’t know that we understood why it was fixed.

In the end, all we had to do was use “pip install -e .” within my package directory. This actually installed to a TOTALLY different spot (~/.local/) than where I had tried to install with the prefix (and where other packages were installed…). I’m still confused that using the prefix command and updating the pythonpath did not work.