GalacticDynamics-Oxford / Agama

Action-based galaxy modeling framework
Other
72 stars 35 forks source link

Error when Importing Agama: dlopen symbol not found in flat namespace #25

Closed um-jglad closed 2 years ago

um-jglad commented 2 years ago

I've tried installing agama a few different ways with varying success on an M1 Macbook Air running macOS 12.4 Monterey. The most recent attempts using pip install --user agama or python setup.py install --user appear to compile fine in an anaconda environment with python 3.8, but produce an error when attempting to import agama:

% python
Python 3.8.13 (default, Mar 28 2022, 06:13:39) 
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import agama
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/jglad/Downloads/Agama-master/agama.so, 0x0002): symbol not found in flat namespace '__ZNKSt12__basic_fileIcE7is_openEv'

Any advice or help would be appreciated.

um-jglad commented 2 years ago

Ok, I'm pretty sure I've done nothing other than maybe reboot and new shell session, and the error is gone!?

eugvas commented 2 years ago

hmm, weird indeed, but there are some installation problems on Apple M1 systems which I haven't fully resolved yet, so not sure if it was related..

eugvas commented 2 years ago

well, actually the problem is still there, we haven't managed to solve it yet. First, it is not related to M1 (same happens on an Intel Mac workstation). Second, it only happens when compiling the code with Clang. By default, the setup script in agama picks up the system-default compiler, but apparently (and hideously!), distutils (the standard way of compiling C++ extension modules from within Python) prefers to use GCC, which works fine. I may try to change the setup script so that it tries GCC first, then falls back to the system-default compiler (which is Clang in the case of MacOS). But this may prevent people from using Intel C, for instance..

um-jglad commented 2 years ago

FWIW I was also able to seemingly compile, run python setup.py test, and import successfully using python setup.py install --user by installing gcc-11 with brew and making an alias for cc='gcc-11' in my .zshrc file.