mcmtroffaes / pycddlib

A Python wrapper for Komei Fukuda's cddlib.
http://packages.python.org/pycddlib/
GNU General Public License v2.0
58 stars 9 forks source link

symbol not found in flat namespace (Mac OS) #68

Open immortalzal opened 1 month ago

immortalzal commented 1 month ago

Hi! I am using a program that includes pycddlib as a package. I use a M1 Macbook Pro. When I tried to run the program, it showed the following message:

Screenshot 2024-07-23 at 12 03 12 AM

I tried to troubleshoot to see what was wrong:

Screenshot 2024-07-23 at 12 04 34 AM

Prior to running the program, I had already installed the newest version of gmp via brew. I also had pycddlib installed.

Screenshot 2024-07-23 at 12 06 36 AM

I encountered no problems while installing pycddlib. I am unsure what is going on here. Any help would be greatly appreciated, and I thank you in advance for your time!

mcmtroffaes commented 1 month ago

It appears there's a problem with the installation of gmp on the system... It's not finding the symbol, which, I guess, can be caused by not having the library (the *.so file for gmp) in your library path.

I don't use mac, so I'm sorry I can't be more helpful beyond this!

bobmyhill commented 1 month ago

I had a look on my Mac and updated GMP and pycddlib. I can't reproduce. The only thing I wondered was whether there's some python version conflict causing the gmp library not to be in path... You are using python 3.10 but I think the new Mac OS uses 3.12 by default. Perhaps worth an update?

immortalzal commented 1 month ago

I've installed Python 3.12 and it still shows the same error.

Screenshot 2024-08-07 at 4 57 44 PM

I really appreciate you guys taking the time to help. Thank you both.

mcmtroffaes commented 1 week ago

Did you manage to resolve this?

One guess is that you need to update your DYLD_LIBRARY_PATH to point to the folder where the gmp library that was used install pycddlib is located. On github actions this is /opt/homebrew/lib/, and so you'd do

export DYLD_LIBRARY_PATH=/opt/homebrew/lib/:$DYLD_LIBRARY_PATH

(Note that this isn't actually needed on github actions; either it is already included by default or the build was static... but if I had an ImportError like yours, I'd try to solve it this way.)

If you installed with homebrew, it seems that brew --prefix will give you the path (without the "/lib/" part, you'll have to add that).

Finally, you can also try

find /usr /opt -name "libgmp.*"

to search your system for where you've installed gmp.

I don't have Mac OS myself so I'm sorry I can't be more helpful beyond trying to give sensible pointers. But I hope at least one of these pointers help.

mcmtroffaes commented 9 hours ago

Somewhat relevant to this issue is that I've created a new package that can be installed without gmp, as some users do not have the ability to install gmp on their system (notably, on Google Colab):

pip install pycddlib-standalone

Note this is still in beta, and the API has changed quite a lot, so it probably won't work for the external program that you are using (until they update to use the new interface), but at least the user experience should be a lot smoother with this.