[Note] What to do if the Qt library conflicts between pyqt and opencv

Symptoms

environment

conditions Contents
OS macOS Catalina 10.15.6
python environment pyenv + Anaconda2020-02[^1]
- Pyqt5 5.15.0
- opencv-python 4.2.0.32

Contents

ʻWhen I ran a program that uses opencv-python and PyQt5` at the same time, it quits with a lengthy error message.

objc[54311]: ClassQMacAutoReleasePoolTracker is implemented in bot /Users/hogehoge/opt/anaconda3/lib/python3.7/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore (fugafuga) and /Users/hogehoge/opt/anaconda3/lib/python3.7/site-packages/cv2/.dylibs/QtCore (fugafuga). One of the two will be used. Which one is undefined.
objc[54311]: Class QT_ROOT_LEVEL_POOL__THESE_OBJECTS_WILL_BE_RELEASED_WHEN_QAPP_GOES_OUT_OF_SCOPE (Same as above).
objc[54311]: Class KeyValueObserver (Same as above).
objc[54311]: Class RunLoopModeTracker (Same as above).
(Omission)

You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.
qt.qpa.plugin: Could not load the Qt platform plugin "cocoa" in "/Users/hogehoge/opt/anaconda3/lib/python3.7/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: cocoa, minimal, offscreen, webgl.

I almost gave up with this amount of messages. But I couldn't help doing it.

approach

Reference: https://qiita.com/dragonemox/items/2d17db7620979711d65c

Put it back in for the time being. (I wonder why I put it in recently)

pip uninstall pyqt5
pip install pyqt5

If this doesn't work (though you can't really do it)

pip uninstall pyqt5
conda install pyqt

The cause remains unknown.

Things that may be helpful

at the end

Stop using Anaconda on your mac.

[^ 1]: Same for miniconda3-latest

Recommended Posts

[Note] What to do if the Qt library conflicts between pyqt and opencv
What to do if the user name is changed and the pyenv library path does not pass
Note: What to do if pip install fails
What to do if the latest Jupyter Notebook and nb extensions don't work
What to do when only the window is displayed and nothing is displayed in pygame Note
What to do if you get the error "Error: opencv3: Does not support building both Python 2 and 3 wrappers" when installing openCV 3
What to do if the package dependency cannot be repaired
What to do if yum breaks
What to do if the inode is exhausted on EC2 Linux
What to do if you can't use the trash in Lubuntu 18.04.
What to do if you cat or tail a binary file and the terminal is garbled
What to do if the Pipenv environment is corrupted by updating Homebrew
[Introduction to Python] What is the difference between a list and a tuple?
What to do if ipython and python start up with different versions
What to do if the yum command fails to set locale, defaulting to C
What to do if the Chainer (Windows) sample mnist terminates with WinError 183.
What to do if the server doesn't start with python manage.py runserver
Isn't Qt the strongest library if you want to easily output SVG?
Let's Encrypt updated! What to do if the certbot renew command doesn't work
What to do if abort is displayed when inputting camera video in OpenCV
What to do if a version error occurs in the selenium Chrome driver
What to do if (base) is displayed at the beginning of the Mac terminal
What is the difference between `pip` and` conda`?
What to do if pipreqs results in UnicodeDecodeError
What to do if you can't pipenv shell
What to do if mod_fcgid cannot resolve UnicodeEncodeError
What to do if rails s doesn't work
What to do if pip cannot be installed
What to do if atom autocomplete-python doesn't work
What to do if Docker-sync suddenly stops working
What to do if "amazon-linux-extras" → "No module named amazon_linux_extras"
What is the difference between Unix and Linux?
What to do if the Microsoft Store opens even if you run python on Windows
What to do if pvcreate produces a lot of WARNING and cannot be created
What to do if the print command itself causes an error in Maya python
What to do if the progress bar is not displayed in tqdm of python
How to install and use pyenv, what to do if you can't switch python versions
What to do if Python does not switch from the System version in pyenv
What to do if you get the error ʻERR_FEATURE_UNAVAILABLE_ON_PLATFORM` when using ts-node-dev on Linux
What to do if you can't hit the arrow keys in the Python interactive console
What to do if you run python in IntelliJ and end with an error
[Introduction to Infectious Disease Models] What is the difference between the April epidemic and this epidemic? .. .. ‼
What to do if pip install fails in Xcode 5.1
What to do if you can't pip install mysqlclient
No module named What to do if you get'libs.resources'
ModuleNotFoundError: No module What to do if you get'tensorflow.contrib'
What to do if you install openCV3 and make a symbolic link, but when you do "import cv2", "No module named'cv2'" appears
What is the difference between usleep, nanosleep and clock_nanosleep?
What to do if a UnicodeDecodeError occurs in pip
How to use argparse and the difference between optparse
What to do if pip install fails to install dependent libraries
What to do if sys / cdefs.h does not exist
What to do if pyenv is not enabled (zsh)
[* CentOS 6.10] What to do if you cannot add the IUS Community Project repository on CentOS 6.5 (VirtualBox)
Make a note of what you want to do in the future with Raspberry Pi
What to do if the image is not displayed using matplotlib etc. in the Docker container
What to do if you get Swagger-codegen in python and Import Error: No module named
What to do if you try to push to git hub and get "fatal: The current branch develop / feature / discussion has no upstream branch."
What is the difference between a symbolic link and a hard link?
Set the environment variables required for PySide (Qt4) and PyQt (Qt5)
What to do if ʻarguments [0] .scrollIntoView ();` fails in python selenium