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

running open cv on a Mac M1 machine with python 3.9 natively #550

Closed
mv96 opened this issue Oct 1, 2021 · 4 comments
Closed

running open cv on a Mac M1 machine with python 3.9 natively #550

mv96 opened this issue Oct 1, 2021 · 4 comments
Assignees

Comments

@mv96
Copy link

mv96 commented Oct 1, 2021

pip command used to install - pip install opencv-python

----> 9 import cv2

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/init.py in
----> 5 from .cv2 import *

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/cv2.cpython-39-darwin.so, 2): Library not loaded: /opt/homebrew/opt/ffmpeg/lib/libavcodec.58.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/cv2.cpython-39-darwin.so
Reason: image not found

Any help would be appreciated ?

@asenyaev
Copy link
Contributor

asenyaev commented Oct 5, 2021

@mv96, I've tested the latest version of opencv-python on Mac Mini with M1 and did not have any issues. I've tried to reproduce it using following commands:

arch -arm64 python3.9 -m pip install --user --no-cache --force-reinstall opencv-python
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_extra.git
export OPENCV_TEST_DATA_PATH=$(pwd)/opencv_extra/testdata
cd opencv
arch -arm64 python3.9 modules/python/test/test.py -v --repo .

And one more short test getting the build information in a self-created test.py file:

import cv2 as cv
from cv2 import *

print(cv.getBuildInformation())

Running this command:

arch -arm64 python3.9 test.py

Could you share more details? I would try to reproduce and solve your issue.

@yongce
Copy link

yongce commented Oct 5, 2021

@asenyaev I tried your steps and got the same error.

$ arch -arm64 python3.9 -m pip install --user --no-cache --force-reinstall opencv-python
Collecting opencv-python
Downloading opencv_python-4.5.3.56-cp39-cp39-macosx_11_0_arm64.whl (10.7 MB)
|████████████████████████████████| 10.7 MB 4.2 MB/s
Collecting numpy>=1.21.0
Downloading numpy-1.21.2-cp39-cp39-macosx_11_0_arm64.whl (12.4 MB)
|████████████████████████████████| 12.4 MB 3.5 MB/s
Installing collected packages: numpy, opencv-python
WARNING: The scripts f2py, f2py3 and f2py3.9 are installed in '/Users/tuyongce/Library/Python/3.9/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.21.2 opencv-python-4.5.3.56

$ arch -arm64 python3.9 modules/python/test/test.py -v --repo .
Traceback (most recent call last):
File "/Users/tuyongce/work/ai/opencv/modules/python/test/test.py", line 22, in
from tests_common import NewOpenCVTests
File "/Users/tuyongce/work/ai/opencv/modules/python/test/tests_common.py", line 13, in
import cv2 as cv
File "/Users/tuyongce/Library/Python/3.9/lib/python/site-packages/cv2/init.py", line 5, in
from .cv2 import *
ImportError: dlopen(/Users/tuyongce/Library/Python/3.9/lib/python/site-packages/cv2/cv2.cpython-39-darwin.so, 2): Library not loaded: /opt/homebrew/opt/ffmpeg/lib/libavcodec.58.dylib
Referenced from: /Users/tuyongce/Library/Python/3.9/lib/python/site-packages/cv2/cv2.cpython-39-darwin.so
Reason: image not found

@asenyaev
Copy link
Contributor

asenyaev commented Oct 6, 2021

@yongce, yes, I've found the source of the problem - no libs inside a package. It was built using libs in a local environment and wasn't linked to a package.

I'm working on it, fix will be added as soon as possible.

@asenyaev
Copy link
Contributor

asenyaev commented Oct 8, 2021

@mv96 @yongce The issue was fixed and changes were merged into master. The next release of packages will upload fixed wheels.

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

4 participants