I am using WSL, and when running some Python code with OpenCV that needs to open a different window, it throws an error.
This is the code:
import cv2 as cv
image = cv.imread("images/pic.jpg")
cv.imshow(0)
cv.waitKey(0)
And this is the error I get
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/user/.local/lib/python3.8/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: xcb.
Aborted (core dumped)
I faced a similar problem. As recommended by most people, I tried putting a symbolic link and installing new packages. I changed QT_PLUGIN_PATH, I exported AT_DEBUG_PLUGINS=1 also. Those options did not seem to work for me. I was on Windows 10 with WSL2, running OpenCV cv2.image which was not showing. Errors were said to be qt related (as stated by #josh merrian).
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/user/.local/lib/python3.8/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: xcb.
Aborted (core dumped)
Try running xeyes.
sudo apt-get install x11-apps
xeyes
Does it run? If not you may be having the same problem I had.
In my case, I learnt that in WSL2 we need to have an Xserver to deploy Ubuntu oriented graphical applications. I read about Xming and also VcSrv. I tried VcSrv and it worked for me.
See: https://www.stat.ipb.ac.id/agusms/index.php/2019/01/15/how-to-run-graphical-linux-applications-on-bash-on-ubuntu-on-windows-10/
Hope this helps somebody out there. Goodluck.
You need to enable your environment for GUI application on WSL.
Using the GUI for enabling Windows features
Open the Start Menu and search Turn Windows features on or off
Select Windows Subsystem for Linux
Click OK
Restart your computer when prompted
upgrade OpenCV, with the following command using pip
pip3 install --upgrade opencv-python==4.3.0.36
Related
Unable to run/debug run in my python file. I KNOW I downloaded python on my computer. I know I downloaded the extension in VS code. Every time I try to run even a simple print("abc") line of code I get nothing in the terminal and a message that reads
"Extension activation failed, run the 'Developer: Toggle Developer Tools' command for more information."
in addition to
"Python extension loading..."
and the extension never seems to finish loading its been hours.
How do I fix this I am working out of Windows
For example I have "Extension" named Python in the image below that gets updated or installed by vsCode automatically
You have to wait for the "Extensions" to be installed.
Make sure you have an internet connection.
make sure you have a fast internet connection so that it can be installed faster.
After installation restart "vsCode"
If it doesn't work for you, try uninstalling the extension and reinstalling it
This is all I know and it happened to me
Don't know the reason, for me I installed a pervious version for python EXTENSIONS, and issue fixed screenshot
Navigate to the extensions and you'll find the extensions whose reload is required. Press reload and wait for the extension to refresh. Check the error message at the bottom to see if it still persists.
For me this problem occurred when updating VS code to version 1.75.0 and python extension version was 2022.20.2, problem fixed when updating python extension to version 2023.2.0
I installed pygame through cmd using pip install pygame which can be seen in the ss. For some reason im unable to import it in my main.py file. Is there some way for me to fix this?(screenshot of terminal and vscode file)
I faced the same issue, but I had used the terminal. What I had done:
Deleted pygame which was installed via pip.
Installed it from the official website.
Then imported pygame. It fixed the issue.
I use linux
Alternatively, you can open the app installer of your device and search "pygame". Hopefully the module shows up.
I use dnf install opencv.
sudo dnf install opencv opencv-contrib opencv-core opencv-devel opencv-doc python3-opencv
Then I run the python code:
import cv2 as cv
img = cv.imread('/home/a/dog.jpeg')
cv.imshow('dog', img)
Then I got the following error:
QSocketNotifier: Can only be used with threads started with QThread
My system is Fedora release 34.
Why and how to solve it?
The problem is about Wayland. Most probably your display server is Gnome with Wayland as the default. Solution 1:
switched the session to Gnome with Xorg which uses X11 as the display server, the Qt GUI
looks normal.
Solution 2:
I guess it is a common bug in fedora. I've found many similar issues with a quick search for different fedora versions ( 30, 31, 32 SO thread, 33). That's why, you can try to build opencv and set WITH_QT flag OFF from the source rather than dnf package manager.
Not sure about the backbone of the problem but the bug tracker may help if RedHat cares.
I'm trying to connect my python Backend with Ikeas's Tradfri to control it from my own app.
I found that for this communication I need DTLSSocket and libcoap, but according to this repo here (https://github.com/ggravlingen/pytradfri/issues/97) there are some major problems installing these libs on windows.
I tried it myself and it's still not working. Installing DTLSSocket on Windows results in:
ERROR: Failed building wheel for DTLSSocket
Of course I could use a VM or the WSL service to build a linux environment, but that's actually not what I want.
Is anyone of you aware of another solution how to connect to the tradfri gateway or knows how to install the required libs on Windows?
Thanks!
pip install conda
Then try again.
I'm trying to install several plug-ins in Spyder IDE, such as:
unit test
notebook
line profiler
spyder-terminal
memory-profiler
spyder-report
But unfortunately, I've got some serious problem. The installation was good, though I couldn't install spyder-vim and conda-manager plug-in for some unknown reason.
But the thing was horrible after launching the IDE. It's just broken somehow and not responding. Mouse unclickable. The interface was totally messed up.
After removal of these plug-ins, I again manually installed those plug-ins and tried to figure it out which plug-in caused this.
This time I only installed
unit test spyder-report notebook terminal
and now after launching, I saw interface was a little bit finer than before and discovered some problem in the spyder-report plug-in. While rendering report to HTML it showed the following error:
signal only works in main thread
I'm not sure whether I'll try other plug-in, but everything is pretty OK now except the spyder-report plug-in. I googled it for a day, but I found no effective solution.
You didn't say which version of Spyder and Python you installed, nor which operating system you are using. So, using Debian unstable and Python 3.6.5, I installed:
spyder3, 3.2.6
spyder-common, 3.2.6
python3-spyder, 3.2.6
python3-spyder-memory-profiler, 0.1.2
python3-spyder-line-profiler, 0.1.1
python3-spyder-reports, 0.1.1
python3-spyder-unittest, 0.3.0
as well as all of their dependencies. After that, I started spyder3 without any problems (except that I have to use the Spyder 2 icon theme, because it can't find the Spyder 3 icons). The Reports tab works fine, no "Signal only..." error.
The problem with spyder-vim seems to be that no actual release has been made yet, so pip3 install spyder-vim doesn't find anything.
Last, I added the terminal plugin with pip3 install spyder-terminal.
Again, after that all is working fine.