sibirrer / fastell4py

Python Wrapper of the FASTELL code by Rennan Barkana
MIT License
2 stars 3 forks source link

ImportError: cannot dynamically load executable #1

Closed Christovis closed 3 years ago

Christovis commented 5 years ago

I have installed fastell4py on a remote HPC. When I want to import it however (such as in Lenstronomy) I am faced with the following error: File ".../python3.6/site-packages/lenstronomy/LensModel/Profiles/spemd_smooth.py", line 20, in __init__ from fastell4py import fastell4py File ".../python3.6/site-packages/fastell4py-0.1.0-py3.6-linux-x86_64.egg/fastell4py/fastell4py.py", line 14, in <module> from fastell4py import _fastell ImportError: .../python3.6/site-packages/fastell4py-0.1.0-py3.6-linux-x86_64.egg/fastell4py/_fastell.cpython-36m-x86_64-linux-gnu.so: cannot dynamically load executable The reason could be, that _fastell.cpython-36m-x86_64-linux-gnu.so was compiled without the -shared flag. However I am not sure about this. since I do not receive the above mentioned error on my local machine.

Does anyone know a possible solution?

sibirrer commented 5 years ago

Did you get a suspicious message when you 'install' fastell4py with python setup.py install? It can happen that the fastell4py python path gets added (pythonic install) but the fortran compilation failed. You could see such a behavior in the messages following the python setup.py command. This may happen if the fortran compiler used is incompatible with the fortran code in this package.

Christovis commented 5 years ago

I run against this problem and got a failed with exit code 1 error. But eventually I got the right environment set up and could install it without and suspicious message. I could also mention that on the remote machine I use python 3.6.5 and on my local machine I use python 3.7.4. However I don't think it has anything to do with that.

sibirrer commented 5 years ago

maybe you have to add in the installation --shared I just googled the error message and found something potentially similar https://stackoverflow.com/questions/43002915/loading-a-shared-library-cuda-in-python-via-ctypes-cannot-dynamically-load

Christovis commented 5 years ago

Exactly. It seems to be the missing -shared flag in the compilation of the cython file. However, I can't seem to find where this is happening during the installation of fastell4py. I can only see that I have the already compiled _fastell.cpython-36m-x86_64-linux-gnu.so file and that it is copied into the new .../python3.6/site-packages/folder. So it does not seem to be compiled during the installation.

sibirrer commented 5 years ago

Did you put the -shared flag in the installation? If not, you should probably do that.

Christovis commented 5 years ago

I am sorry that I don't quite understand. Adding the flag in the python installation of fastell4py as: python setup.py install --user --shared, does not work, since the --shared flag can't be recognized (or any other alteration such as -s ...). Do you mean something different?

sibirrer commented 5 years ago

sorry, I was confused. I am unfortunately not familiar with fortran compilers/requirements for specific environments and did not experience myself the issue you are reporting.

sibirrer commented 3 years ago

This issue has been open for a while, and I am not sure you found a solution @Christovis. In fact, when using lenstronomy, there is an elliptical power-law profile implemented that does not require fastell4py to run. It is called 'EPL' in the lenstronomy conventions. Let me know if you have questions. In the meantime I close this issue but feel free to reopen it.