Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run using MacOSX #163

Open
adj-smith opened this issue May 22, 2020 · 14 comments
Open

Unable to run using MacOSX #163

adj-smith opened this issue May 22, 2020 · 14 comments

Comments

@adj-smith
Copy link

adj-smith commented May 22, 2020

I consistently get the following when attempting to execute PyMultiNest:

Traceback (most recent call last): File "/Users/[redacted]/Documents/Code/Internal/PMNexperimentMay2020.py", line 139, in <module> pmn.run(Loglike, Prior, ndims,n_live_points=1000,n_params=n_params,outputfiles_basename='./'+ProjectName+'/temp_',resume=False,verbose=True) File "/Users/ajsmit16/Library/Python/3.8/lib/python/site-packages/pymultinest-2.9-py3.8.egg/pymultinest/run.py", line 254, in run File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py", line 386, in __getattr__ func = self.__getitem__(name) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py", line 391, in __getitem__ func = self._FuncPtr((name_or_ordinal, self)) AttributeError: dlsym(RTLD_DEFAULT, run): symbol not found

This is likely related to Issue #160 however the solutions mentioned there did not work for me. I am executing using Python 3 running on macOS Catalina version 10.15.4. I can provide any additional information as needed.

@JohannesBuchner
Copy link
Owner

Try to recompile multinest (clean the build directory beforehand).

@adj-smith
Copy link
Author

Thank you for the quick response. In the MultiNest/Build/ directory I ran
make clean
followed by
make
and then attempted to run PMN again. I encountered the same error.

@adj-smith
Copy link
Author

adj-smith commented May 22, 2020

Additional information, in case it is helpful.

[redacted]:build [redacted]$ echo $DYLD_LIBRARY_PATH

/Users/[redacted]/MultiNest/lib/:/Users/[redacted]/MultiNest/lib/:/Users/[redacted]/MultiNest/lib/:/Users/[redacted]/MultiNest/lib/:

[redacted]:build [redacted]$ ls -al /Users/[redacted]/MultiNest/lib
total 2920

drwxr-xr-x   6 [redacted]  staff     192 May 22 15:51 .

drwxr-xr-x  16 [redacted]  staff     512 May 22 14:16 ..

-rw-r--r--   1 [redacted]  staff     120 May 22 11:52 .gitignore

-rwxr-xr-x   1 [redacted]  staff  680812 May 22 15:51 libmultinest.3.10.dylib

-rw-r--r--   1 [redacted]  staff  803424 May 22 15:51 libmultinest.a

lrwxr-xr-x   1 [redacted]  staff      23 May 22 15:51 libmultinest.dylib -> libmultinest.3.10.dylib

@JohannesBuchner
Copy link
Owner

clean the build directory completely and rerun cmake.

@adj-smith
Copy link
Author

I am still having the issue. I attempted to follow your suggestion. I completely deleted the /MultiNest/ directory, did another git clone, and ran cmake and make again (as sudo just to be sure). However I still encounter the AttributeError on execution.

Possibly related: the documentation refers to the creation of a libmultinest.so shared object in the MultiNest/lib/ directory. However after cmake/make the only files in that directory for me are .dylib and .a files.

@JohannesBuchner
Copy link
Owner

Use ldd to identify the libraries needed by libmultinest.so (ldd libmultinest.so). check with which python (or python3) the python runtime actually used (is it conda?). Then use ldd on it.

Alternatively, you can try UltraNest instead.

@JohannesBuchner
Copy link
Owner

there is also a conda pymultinest package, which installs multinest for you.

@JohannesBuchner
Copy link
Owner

@grburgess suggests that using sudo is unwise, as it can mix python environments. Try without?

@adj-smith
Copy link
Author

adj-smith commented May 26, 2020

otool -L is the Mac equivalent of ldd.

$ otool -L /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3:
    /Library/Frameworks/Python.framework/Versions/3.8/Python (compatibility version 3.8.0, current version 3.8.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

I will take a look at UltraNest and Conda, I have no experience with either. It would be nice to use PMN again, I am familiar with it from research in past years.

Presence or absence of sudo does not appear to affect the result.

Thank you for your assistance. As I said I will try UltraNest, and failing that I think I will use a different environment (I have access to a remote machine in addition to my current system) to see if that makes any difference. If you have any other suggestions I'll try those as well.

@grburgess
Copy link

I think I see something that is a potential problem.

Are you using a virtual environment?

It seems you are also using the MacOS system python, rather than one installed via a package manager or manually. This can cause a gigantic number of issues that are difficult to trace because things become linked to system libraries.

Are you using the system python?

@adj-smith
Copy link
Author

I'm not sure I know the answer to either of your questions. The laptop is not a personal laptop but was issued to me by my employer. As I recall it came with Python 2.7, while I later installed Python 3. I've attempted to run my code both through my normal means (building from Sublime Text Editor) and also through command line execution. Both failed.

I will note that last summer (roughly July, possibly August) I was able to run PMN on this laptop. However enough time has passed since then that I have no idea how many things could possibly have changed.

Regardless, I have opted to use UltraNest and it is working very well. I'll leave this issue open and I'm willing to continue exploring the issue to solve it, if it would be helpful to others. Otherwise I don't plan to keep working with PMN.

@tomasstolker
Copy link

I encountered a similar issue on macOS because the MultiNest library path was not part of os.environ['DYLD_LIBRARY_PATH'] even though I exported the path to DYLD_LIBRARY_PATH beforehand. Possibly it is related to the fact that I am using pyenv but I am not sure.

The way I could solve it is by adding the path manually at the start of the code that I am running as:

import os
os.environ['DYLD_LIBRARY_PATH'] = '/path/to/MultiNest/lib

@westjl
Copy link

westjl commented Jan 22, 2021

I just had this same issue. Setting the system env variable did not seem to help even though doing

echo $DYLD_LIBRARY_PATH

gives the correct path so I'm not sure why pymultinest is not finding it.

Adding the line mentioned above, i.e,:
os.environ['DYLD_LIBRARY_PATH'] = '/path/to/MultiNest/lib'

finally worked for me but I found I actually had to add it into run.py of the pymultinest source before it finally solved the issue. Adding that line into my own code didn't seem to make a difference either. This doesn't seem to be a great solution, but it's at least working for now.

Note that the demo code worked without the fix, but I was running it from inside the MultiNest directory so I'm guessing that's why (but it made troubleshooting even more confusing!)

I'm using Python 3.7 in a conda environment on MacOS 10.14.5

@JohannesBuchner
Copy link
Owner

Is this issue still relevant? If not, could you please explain how it was solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants