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 macOS issue (ImportError: dlopen(...): no suitable image found. Did find: ...: mach-o, but wrong architecture) #223

Closed
thinking-tower opened this issue May 27, 2021 · 2 comments

Comments

@thinking-tower
Copy link
Contributor

Issue description

After installing kp, import kp throws an error.

Code example

# use pip
pip install kp 
# or compile from source
git clone https://github.com/EthicalML/vulkan-kompute.git
git submodule update --init --recursive
python setup.py build
python setup.py install
>>> import kp
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(.../lib/python3.9/site-packages/kp-0.7.0-py3.9-macosx-11-arm64.egg/kp.cpython-39-darwin.so, 2): no suitable image found.  Did find:
        .../lib/python3.9/site-packages/kp-0.7.0-py3.9-macosx-11-arm64.egg/kp.cpython-39-darwin.so: mach-o, but wrong architecture
        .../python3.9/site-packages/kp-0.7.0-py3.9-macosx-11-arm64.egg/kp.cpython-39-darwin.so: mach-o, but wrong architecture

System Info

  • OS: macOS Big Sur 11.2.3
  • Architecture: arm64
  • CMake version: 3.19.6
  • Python version: 3.9
@thinking-tower
Copy link
Contributor Author

thinking-tower commented May 27, 2021

This can be caused by

  • linking to an Intel-based Python library
    • Python3.9 ARM and Python3.8 Intel installed in the same machine
  • compiling in an Intel-based terminal like Visual Studio Code with Rosetta emulation
    • uname -m in emulated Visual Studio Code returns x86_64 for example.

Here's a couple of solutions:

  • Make sure to link to the correct Python library
  • Launch terminal yourself and compile there
  • If you want to compile with an Intel program (Visual Studio Code with Rosetta), pass -DCMAKE_OSX_ARCHITECTURES=arm64 when installing
  • pip install kp with Intel Python instead

See discussions in CMake and Homebrew for more information.

@axsaucedo
Copy link
Member

Closing as fix was merged

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

2 participants