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

Mac M3: x86 version is installed via pip, how to specify arm64? #953

Closed
4 tasks done
CharlieHess opened this issue Feb 8, 2024 · 3 comments
Closed
4 tasks done
Labels

Comments

@CharlieHess
Copy link

System Information

OpenCV Python Version: 4.9.0.80
Operating System / Platform: MacOS Sonoma 14.3
Python Version: 3.10

Detailed description

I am attempting to use opencv-python within Blender's Python scripting environment.

After reading through many issues, e.g., #429, OpenCV claims that arm64 is supported. So I tried:

./python3.10 -m pip install opencv-python

This command works, but is apparently installing the x86 package rather than arm64. Thus, Blender's scripting environment (natively arm64) doesn't like it:

ImportError: dlopen(/Users/charlie/.local/lib/python3.10/site-packages/cv2/cv2.abi3.so, 0x0002): tried: '/Users/charlie/.local/lib/python3.10/site-packages/cv2/cv2.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/charlie/.local/lib/python3.10/site-packages/cv2/cv2.abi3.so' (no such file), '/Users/charlie/.local/lib/python3.10/site-packages/cv2/cv2.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

How do I install binaries that work for my OS?

Steps to reproduce

  1. Have an arm64-based Mac
  2. Install opencv-python

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)
@CharlieHess CharlieHess added the bug label Feb 8, 2024
@opencv-alalek opencv-alalek transferred this issue from opencv/opencv Feb 8, 2024
@opencv-alalek
Copy link

Perhaps platform auto-detection does not work properly in this case.

How do I install binaries that work for my OS?

You could try to download Mac ARM64 wheel package from PyPi explicitly and install it using pip: https://pypi.org/project/opencv-python/#files

@CharlieHess
Copy link
Author

Yes, it is remarkable to see the barren state of Python and its dependents on MacOS. Cursory Google searching ("have 'x86_64', need 'arm64'") reveals thousands of people crying out in desperation. It appears all this pain and suffering could be resolved by—I kid you not—fixing platform auto-detection.

I was able to resolve by specifying --subdir osx-arm64 on my miniforge. How was I supposed to know that? How would anyone know to do that? Is the real answer to platform-specific build issues, "learn platform-specific incantations?" I spent my entire morning looking around the internet for this bit of forbidden fruit. It was actually ChatGPT that gave me the info, and it was so obscure I thought it had hallucinated it—miniforge docs don't even mention it.

In the year of our Lord 2024, 3+ years after ARM64 became the default for every new user on MacOS, these people still need to specify incantations on the command-line to get their platform working. Absolutely unforgivable.

@opencv-alalek
Copy link

Why did you close unresolved issue?

It is better to provide more information about your environment if you really want to have fix with their support.

miniforge

Usually we don't need that. How is it installed? configured?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants