python app - xcb plugin fail - python

My setting: Python 2.7 with anaconda
Recently I have installed OpenCV 3.0 and when I try to do simple image display or I want to run python samples that come with OpenCV, there is a error message:
This application failed to start because it could not find or load the Qt platform plugin "xcb".
I have read many comments that I need to attach .so files to my project but I don't think it's the optimal solution since for most people it works out of a box.
I have no clue what to do. I'm inexperienced. What comes to my mind is only to reinstall everything.

Qt5 works fine with OpenCV 3.1.0. This is what worked for me for resolving the "xcb" error.
Apparently the Anaconda qt and pyqt packages (v4) were shadowing the system v5 version.
If you want to work with Qt5 try removing these via:
conda remove qt
conda remove pyqt
(Ubuntu 16.04, OpenCV 3.1.0, Anaconda 4.1.1, Qt 5)

Okey, I have figured it out.
During cmake I set flag -D WITH_QT=OFF since I read somewhere that it doesnt work for Qt5.x

Related

QT Binaries Problem : Unable to use PySide2

I'm getting the following error when I try to run my code where I want to use PySide2.
objc[18673]: Class RunLoopModeTracker is implemented in both /opt/anaconda3/lib/python3.8/site-packages/PySide2/Qt/lib/QtCore.framework/Versions/5/QtCore (0x11c3c0288) and /opt/anaconda3/lib/libQt5Core.5.9.7.dylib (0x1207e3a80). One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x7fe94dc18af0) is not the object's thread (0x7fe94df34560).
Cannot move to target thread (0x7fe94dc18af0)
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 "" 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.
Abort trap: 6
Unfortunately I have no clue what this means and what to do about it, I tried googling it already but nothing useful has come up!
I'm using Python 3.8.5, PySide 5.15.2 and I'm on Mac OS 10.15.7. Thanks for any help!
I had the same You might be loading two sets of Qt binaries into the same process error with my Qt app when using PyInstaller for packaging.
Using an isolated venv for development, created from anaconda3, everything worked fine! But when the PyInstaller pulled in PySide2 and whatever else it needed from my various env PATHs, the anaconda3 versions of libQt5* that were brought in now conflicted with PySide2 (from my requirements.txt)
After a lots of debugging which dylibs are actually loaded by whom and reading all the SO articles, it slowly dawned on me that anaconda3 was the culprit!!
There is precedent for conda package management conflicting with pip based workflow.
Carlos Cordoba, a Spyder IDE maintainer, has helped folks resolve issues with installs, which while adjacent to our problem, gets to the essence of the anaconda3 && Qt conflict. Have a look at his comments in the accepted answer
I solved my problem by:
Removing anaconda3 from my env paths (like $PATH) and .bashrc, essentially making it invisible.
Deleted old anaconda3 venvs used to develop my app
Installed a fresh python3.9 from python.org (much more lightweight than anaconda), added it to my $PATH in .bashrc, to make it my primary python3
Re-building venvs to test, I redid PyInstaller packaging and ran the generated app, now this error is gone!
For debugging I set export DYLD_PRINT_LIBRARIES=1, which no longer shows multiple conflicting QtCore dylibs being loaded.
What DID NOT work for me, but was very commonly seen on SO:
pip install opencv-python-headless. Ya nope.
unset QT_PLUGIN_PATH. This didn't stop the loading of the conflicting libQt5Core
any combination of uninstall & reinstalling anaconda3, or PySide2.
To solve your problem, because /opt/anaconda3/lib/libQt5Core.5.9.7.dylib is the root of the conflict, I recommend that you uninstall (or move anaconda3 out of the way) and use a python.org version of python3.8 OR ... use anaconda3 in venv (which is isolated) and install your dependencies directly with pip

Installing cx_freeze via msys2

I am trying to write a small gtk application with Python.
I was told that you should use msys2 for MS-Windows. See related question: Setting up developement environment: PyCharm, python-gtk, windows
Now I need cx_freeze. There are wheel-files for windows, but I guess the msys2 environment is different, and that's why installing "cx_freeze" fails (no gcc around).
See files of cx_freeze: https://pypi.org/project/cx_Freeze/#files
Now I am unsure if I am on the right track.
Is there a way to use the ready build wheels from a python which is started in msys2 (In my case C:\msys32\usr\bin\python3.exe)
Installing cx_freeze worked after installing gcc. But now I get this error:
cx_Freeze.freezer.ConfigError: no base named Console
I guess I should not compile cx_freeze and get my environment use the provided wheels.
Update
I leave this question open, because someone else could find a solution and help someone else again. But I switched from gtk to pyside2 (QT). Everything is much easier now.

Error while installing PyQt

I want to install PyQt to use features of the Qt-library for my Python programms. When I execute 'configure.py' in the command window I get the following error:
Error: Make sure you have a working Qt qmake on your PATH.
About my system and what I've done yet: I use Python 3.2 on Windows 7.
First I compiled sip-4.15.5. After getting the error above, I also installed Qt5.2.1. Both installations worked without a problem, but the error stayed the same.
I have tried a solution for apparently the same problem, found on stackoverflow. But it doesn't work for me (exportisn't a windows command, is it?). And I don't use the PyQt installer, because it's only available for Python 2.7 and 3.3.
Thanks.
You can download a PyQt installer for Python 3.2 here at Christoph Gohlke's Python Extension Packages for Windows repository. Whenever I'm looking to install or update a module on Windows, I look there first.

Default installation folder for qt4 on ubuntu

I have quite a moronic question. I installed QT4 on my Ubuntu 3.10 and I want to work with it on Eclipse with python. At some point I need to insert the folder where I installed the QT4 as an external library. The problem is that I have no idea where the computer decided to install it. I installed the QT4 throw the Ubuntu software center. I have tried to look after the folder by searching the folder finder for "QT4" or "PyQt4". I got many results and I added each one of them but still having problems compiling. Can anybody tell me the default folder where the ubuntu software center installs the programs? Or should I remove the QT4 and reinstall it?
Thank you in advance.
It should be possible to get the installation paths like this:
dpkg --listfiles libqt4-core

Anaconda Spyder Qt library error on launch

When launching Spyder from the Anaconda python installation on Linux Mint 13 I get the following error:
Cannot mix incompatible Qt library (version 0x40801) with this library (version 0x40805)
Aborted
$PATH is
/home/ron/anaconda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Has anyone found a work around?
Anaconda web-site indicates that Spyder may not launch correctly on Linux machines.
http://docs.continuum.io/anaconda/
*** Resolved
I am a little sheepish. Discovered that I installed Anaconda as sudo. Reinstalled as indicated in documentation and everything works fine. Thanks everyone for the help.
I use anaconda 1.8 on kubuntu alpha. It uses qt 4.8.5. I can see it with
find $ANACONDA/lib -name '*.4.8.5'
My system qt libs is 4.8.6. I can see it with
find /usr/lib -name "*so.4.8.6"
If Your system qt version is 4.8.5, and anaconda is 4.8.1 -- maybe You can just update anaconda? Try to run
conda update conda
conda update anaconda
Edit
It seems that the problem is spyder picking up Your system libraries. I tried to sheild the libs using evnironment variables LD_LIBRARY_PATH and various qt-related. But nothing works. However simple copying system libs to $ANACONDA/lib solves the problem.
Go to $ANACONDA/lib and move all *.4.8* files to another dir. Then go to /usr/lib/x86_64-linux-gnu (are You using 64 bit?) and copy all *.4.8* to $ANACONDA/lib. That's it: run spyder!
The qtlibs are usually stored as files and links: for example if there's a libQtGui.so.4.8.6 file then there's also a symbolic link libQtGui.so.4.8. You have to copy/move links too.
Edit 2:
There's a suggestion to
unset QT_PLUGIN_PATH
I tried to set it to nothing export QT_PLUGIN_PATH=, but didn't try to unset it.
(Spyder dev here) Just for the record, this is a know bug in Anaconda that hopefully will be fixed in its next version (to be released in October/2014).
For me, the best solution was (inspired by #Adobe's answer) to go to the directory in which Anaconda was installed, then the subdirectory lib and to move all the files libQt* out of the way (I moved them to a temporary subdirectory I created for the purpose). Anaconda will now pick up the system libraries. I expect there will be a problem when I update Anaconda and it installs new Qt libraries, but that's for later.
My version is conda 3.9.1 with python 3.4.3 and qt 4.8.5, installed on Debian testing (current as of today) with libqtcore4 version 4:4.8.6+git64-g5dc8b2b+dfsg-3; the architecture is amd64.
Unsetting QT_PLUGIN_PATH and/or setting it to empty did work in the first instance, in that it allowed me to start spyder, but it has some disadvantages. Most importantly, whenever I tried to plot something using matplotlib and inline graphics, I got the error message "it seems the kernel died unexpectedly" instead of the plot I wanted.

Categories