JohannesBuchner / PyMultiNest

Pythonic Bayesian inference and visualization for the MultiNest Nested Sampling Algorithm and PyCuba's cubature algorithms.
http://johannesbuchner.github.io/PyMultiNest/
Other
191 stars 87 forks source link

macOS pymultinest installation #250

Closed shruti-ramaiya closed 4 months ago

shruti-ramaiya commented 4 months ago

Hello,

I have been trying to install pymultinest on my local machine (macOS) and I've run into some issues which I was wondering if anyone could kindly help me with go about solving

To install pymultinest, following the instructions, I first installed homebrew and then did the following

brew install cmake gcc open-mpi atlas

since Mac comes with lapack and blas already, brew installing these weren't necessary.

'brew install gcc' also installs gfortran, so that requirement was satisfied.

Then, reading some other GitHub installation issues, I made sure that gcc was by default using the homebrew installed version, not the clang apple default version that is already present.

this was all fine.

I then created a osx-arm64 virtual conda environment with python=3.11.5 version and installed the relevant python dependencies,

pip install numpy scipy matplotlib mpi4py progressbar

again, following the instructions.

and finally

pip install pymultinest

within my virtual environment.

Then following the instructions to install multinest,

git clone https://github.com/JohannesBuchner/MultiNest cd MultiNest/build cmake .. make

and then adding this to .bashrc profile,

export DYLD_LIBRARY_PATH=/mnt/users/ramaiyas/MultiNest/lib/:$DYLD_LIBRARY_PATH

now, trying to run the demo code returns this error,

Traceback (most recent call last): File "/Users/shrutiramaiya/Desktop/untitled/check.py", line 30, in pymultinest.run(loglike, prior, n_params, outputfiles_basename='out/',resume = False, verbose = True) File "/Users/shrutiramaiya/anaconda3/envs/multi/lib/python3.11/site-packages/pymultinest/run.py", line 285, in run lib.run(*args_converted) ^^^^^^^ File "/Users/shrutiramaiya/anaconda3/envs/multi/lib/python3.11/ctypes/init.py", line 389, in getattr func = self.getitem(name) ^^^^^^^^^^^^^^^^^^^^^^ File "/Users/shrutiramaiya/anaconda3/envs/multi/lib/python3.11/ctypes/init.py", line 394, in getitem func = self._FuncPtr((name_or_ordinal, self)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: dlsym(RTLD_DEFAULT, run): symbol not found

I am unable to understand what is causing this and have been trying to fix this for a few days but to no avail. When installing multinest and pymultinest on the remote server we use, I followed the same steps but didn't get this error, just the expected error according to the docs,

ERROR: Could not load MultiNest library "libmultinest.so" ERROR: You have to build it first, and point the LD_LIBRARY_PATH environment variable to it!

and this was solved by adding the line to my .bashrc which allowed everything to work as normal.

I have checked other GitHub issues with similar problems, but I am unable to make a sure link, as I wish to make sure everything is contained in a virtual environment.

However, I really do need to have a copy of this software working on my local computer and I cannot seem to find the best way to perform this installation for a macOS and make sure everything is cleanly kept inside a conda environment so it doesnt mess with other dependencies or code I have for other work. I am aware there are others in this forum who have had similar issues but none in reference to conda environments so any insight on this would be very helpful

thank you

JohannesBuchner commented 4 months ago

Have a look through the existing MacOS issues, maybe mac users have left useful ideas there: https://github.com/JohannesBuchner/PyMultiNest/issues?q=is%3Aissue+macos

shruti-ramaiya commented 4 months ago

Thanks for the quick response. Let me try once more