ImportError: dlopen(/Users/Desktop/myapp/target/myapp_mac/cv2/cv2.cpython-36m-darwin.so, 2)
Posted
技术标签:
【中文标题】ImportError: dlopen(/Users/Desktop/myapp/target/myapp_mac/cv2/cv2.cpython-36m-darwin.so, 2)【英文标题】: 【发布时间】:2019-07-22 10:44:13 【问题描述】:我在 MacOS 中使用 Pyinstaller 和 OpenCV。构建我的独立应用程序后,我收到以下错误。我尝试了不同版本的模块,但对我没有任何帮助。
我正在使用
MacOs 版本:10.14.5 蟒蛇:3.6 pyinstaller:3.4 opencv-python:3.4.5错误:
File "main.py", line 19, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages/cv2/__init__.py", line 3, in <module>
: Symbol not found: __ZN10QBoxLayout10invalidateEv
Referenced from: /Users/Desktop/myapp/target/myapp_mac/cv2/cv2.cpython-36m-darwin.so
Expected in: /Users/Desktop/myapp/target/myapp_mac/PyQt5/../QtGui
in /Users/Desktop/myapp/target/myapp_mac/cv2/cv2.cpython-36m-darwin.so
【问题讨论】:
您使用的是哪个版本的 Qt,以及哪些绑定,PySide2 或 PyQT5?我有这个确切的错误,我正在试图找出它。应用程序运行但在被 PyInstaller 冻结时不运行 【参考方案1】:简而言之,根据您的项目,尝试使用包opencv-python-headless
而不是opencv-python
我刚刚得到这个为我自己工作。问题似乎是包opencv-python
链接到Qt4,py 安装程序从PySide2 复制Qt5 二进制文件,因此找不到该符号。
来自opencv-python-headless
:
$ otool -L venv/lib/python3.7/site-packages/cv2/cv2.cpython-37m-darwin.so
venv/lib/python3.7/site-packages/cv2/cv2.cpython-37m-darwin.so:
/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
@loader_path/.dylibs/libavcodec.58.35.100.dylib (compatibility version 58.0.0, current version 58.35.100)
@loader_path/.dylibs/libavformat.58.20.100.dylib (compatibility version 58.0.0, current version 58.20.100)
@loader_path/.dylibs/libavutil.56.22.100.dylib (compatibility version 56.0.0, current version 56.22.100)
@loader_path/.dylibs/libswscale.5.3.100.dylib (compatibility version 5.0.0, current version 5.3.100)
@loader_path/.dylibs/libavresample.4.0.0.dylib (compatibility version 4.0.0, current version 4.0.0)
/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
/System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 1070.22.0)
/System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1504.82.104)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1349.64.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1349.63.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
来自opencv-python
:
$ otool -L venv/lib/python3.7/site-packages/cv2/cv2.cpython-37m-darwin.so
venv/lib/python3.7/site-packages/cv2/cv2.cpython-37m-darwin.so:
/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
@loader_path/.dylibs/libavcodec.58.35.100.dylib (compatibility version 58.0.0, current version 58.35.100)
@loader_path/.dylibs/libavformat.58.20.100.dylib (compatibility version 58.0.0, current version 58.20.100)
@loader_path/.dylibs/libavutil.56.22.100.dylib (compatibility version 56.0.0, current version 56.22.100)
@loader_path/.dylibs/libswscale.5.3.100.dylib (compatibility version 5.0.0, current version 5.3.100)
@loader_path/.dylibs/libavresample.4.0.0.dylib (compatibility version 4.0.0, current version 4.0.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 22.0.0)
/System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate (compatibility version 1.0.0, current version 4.0.0)
/System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation (compatibility version 1.0.0, current version 2.0.0)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 1070.22.0)
/System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0)
@loader_path/.dylibs/QtGui (compatibility version 4.8.0, current version 4.8.7)
@loader_path/.dylibs/QtTest (compatibility version 4.8.0, current version 4.8.7)
@loader_path/.dylibs/QtCore (compatibility version 4.8.0, current version 4.8.7)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1349.64.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1349.63.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
我确实读过,如果您的代码没有调用 cv2.imshow(...)
,则可以使用无头。我将进一步调查,因为 windows 版本不附带 qt 二进制文件并且没有同样的问题
【讨论】:
以上是关于ImportError: dlopen(/Users/Desktop/myapp/target/myapp_mac/cv2/cv2.cpython-36m-darwin.so, 2)的主要内容,如果未能解决你的问题,请参考以下文章
ImportError:dlopen(//anaconda3/lib/python3.7/site-packages/MySQLdb/.. 2):未加载库:@rpath/libmysqlclient.
ImportError: dlopen(/Users/Desktop/myapp/target/myapp_mac/cv2/cv2.cpython-36m-darwin.so, 2)