-
Notifications
You must be signed in to change notification settings - Fork 856
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
macOS crash in imshow with Qt5.15 #376
Comments
As a hotfix I'll publish new packages with Qt downgraded to 5.13. This issue needs to however solved somehow in the future. |
What timing! Stumbled upon this problem just 30 minutes ago, I'll have a look if it works. |
Note that there is no new release yet, it will take a couple of days to go back to Qt 5.13. But it would be good if someone could have a look into copying the |
Here is also some of the existing plugin copying code: https://github.com/skvark/opencv-python/blob/d356af12a31fbcb6b7a82372555a7569639bb483/setup.py#L189 |
Qt is now forced to version 5.13.2 on macOS which should work as a temporary fix. New versions should be available in PyPI during next few days. |
@skvark I notice after upgrading to opencv-python 4.4.0.40 or 4.4.0.42 (using pip install opencv-python) on macOS 10.12 there are issues with cv2.imshow(). Zoom and pixel/location functionality is broken. I've tracked this down to QT not being included in the new pypi package for macOS, but I don't know why this is, especially based on this thread which mentions it being updated. I've tried building the wheel locally as well and QT is no longer available under the listed GUI in cv2.getBuildInformation(): GUI: I was previously on opencv-python 4.1.1.26 where QT is listed under GUI, and cv2.imshow is working fine. I was upgrading for SIFT support as well as other new opencv features but this is a blocker as I have tools built with cv2 which do not work without QT GUI. On 4.1.1.26 cv2.getBuildInformation(): GUI: Is there something I need to do for QT to be enabled or is this related to the other QT issues? I am wondering if anyone else is seeing this on MacOS as well |
Qt should be enabled in the macOS builds (Qt 5.13). This thread tracks specific issue with Qt 5.15 which has been solved by not using version 5.15. Post the output of Edit: I do not have a Mac, but confirmed that Qt is included by downloading and extracting macOS wheel: |
Package 4.4.0.42 uses Qt:
|
Thanks @mshabunin! @jdifran Please check that you are actually using the correct pre-built package / your environment is consistent. It's highly unlikely that I could fix the issue you are having in this repository. |
Thanks @skvark and @mshabunin , I am assuming this is due to being on an older macOS version (10.12) and Xcode 9 where QT5 requires per their support docs: macOS 10.13, 10.14, 10.15 | x86_64 and x86_64h | Xcode 11 (10.15 SDK) Is this just a case of QT getting excluded during the install due to the wrong platform requirements? I notice I see this with other versions of opencv-python (4.3) besides the ones that include QT 4.8.7. I am assuming this is a user requirements issue as this point which is why it works in 4.1.1.26 |
Qt is always included in the pre-built non-headless packages ( The latest pre-built wheels have minimum requirement of macOS 10.13 (see: https://github.com/skvark/opencv-python#backward-compatibility). Therefore, I believe that your problem is that Easiest way to fix this would be of course to upgrade to latest macOS version. Otherwise you will have to learn how to configure OpenCV build system to find your Qt SDK and build OpenCV manually. |
The most recent release (4.5.1.48) drops Qt support on macOS. If you need Qt support, consider contributing. |
@skvark Just encountered this issue on macOS. As I understand you need to figure out a way copying the Info.plist file to the packages. Could you elaborate and I'll see whether I could help. Thanks. |
4.4.0.40 is the only build that has this issue. The latest packages do not have Qt so you should not encounter the issue anymore. However, if you need Qt and want to help to add it back to the packages, then you can help by looking into the I'm not familiar with macOS software packaging requirements, so I can't help much. All I know is that Qt probably has the |
Here you can find the link to relevant parts in Qt's source: opencv/opencv#18079 (comment) Apple's docs: https://developer.apple.com/documentation/corefoundation/cfbundle?language=objc#overview |
Here Qt tries to search for a bundle named This might be also relevant: https://developer.apple.com/documentation/corefoundation/1537085-cfbundlegetmainbundle?language=objc (https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/global/qlibraryinfo.cpp#n194) |
Yeah went through those links but it's quite hard to figure out what's going on by just looking at source. I also tried setting os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] to the system Qt5 installation but got the same error. Will keep looking. |
I believe that the QT_QPA_PLATFORM_PLUGIN_PATH and the qt plugins folder is not relevant in this case. QtCore shared lib is trying to load the macOS bundle from somewhere, maybe directly next to the QtCore shared library. On Linux they are located in here: |
Another thing to try is to place the bundle / file directly next to the |
On macOS there are only |
Tried various locations following macOS bundle structures Applications, Frameworks and Loading Bundles, and Qt docs, but with no luck. The cv2 package doesn't look like any apple bundle (changing the cv2/qt folder to Contents to mimic an application bundle didn't work either), which in the case of PyQt it resembles a Framework. Then I came across this article Qt is relocatable, where it states that you can turn off this relocation feature Can/Should this be done during the building process of opencv-python? |
It requires full rebuild of Qt. It might help, but too much work to maintain separate build and it would take ages to build in the CI pipeline. This comment in the Qt sources indicates that the Bundle location is relative to the QtCore shared library: https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/global/qlibraryinfo.cpp#n487 Which means in practice that the |
Placing plist directly under .dylibs or .dylibs/Resources didn't work. Found this link and related discussions. Seemed relevant since we're shipping Qt without frameworks too. |
It seems that the only solution is to use a custom Qt build. That would require some custom repository to build and package it as a Homebrew bottle for example. Qt cannot be built as a part of the current build pipelines since it is such a large and heavy project. |
The most recent release (4.5.1.48) drops Qt support on macOS and should fix this issue. |
Related issue: #423 |
Tested with OpenCV-Python 4.5.1, works without issues. |
See opencv/opencv#18079 for background.
I do not own a Mac so I cannot fix this easily by myself without trial and error which will take a lot of time. As a summary,
Info.plist
file should exist in the packages.Similar issue in PyQt (note that their package structure is different): https://riverbankcomputing.com/pipermail/pyqt/2020-January/042419.html
Related things in this repository:
The text was updated successfully, but these errors were encountered: