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

Python importError when building PyNomad interface for Apple M1 chip (apple ARM64 or intel X86_64) #70

Open
ctribes opened this issue Mar 25, 2022 · 0 comments

Comments

@ctribes
Copy link
Contributor

ctribes commented Mar 25, 2022

When using Clang compiler with OSX on Apple M1 chip, after building PyNomad successfully, when importing PyNomad in Python

import PyNomad
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/christophe/.local/lib/python3.9/site-packages/PyNomad.cpython-39-darwin.so, 0x0002): symbol not found in flat namespace '__ZN9NOMAD_4_210Parameters17_typeOfAttributesE'

or

ImportError: dlopen(xxxx/PyNomad.cpython-39-darwin.so, 0x0002) .... 
(mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))

This issue can be resolved by forcing the architecture to X86_64 when configuring the cmake build with a flag like -DCMAKE_OSX_ARCHITECTURES=x86_64. This is required when Python binaries for the API are x86_64. This can be tested with the command file. For example,

>> file /opt/homebrew/anaconda3/bin/python
/opt/homebrew/anaconda3/bin/python: Mach-O 64-bit executable x86_64

In this case, the nomad binaries must all be x86_64, which is not the default when building with Clang.

It is important, to remove the build directory and the PyNomad.cpython-39-darwin.so in
$NOMAD_HOME/interfaces/PyNomad to make sure all PyNomad binaries are deleted before building again.

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

1 participant