Coder Social home page Coder Social logo

Comments (26)

nofreewill42 avatar nofreewill42 commented on July 19, 2024 131
  1. sudo apt install libgtk2.0-dev pkg-config as the prompt says for Ubuntu users -> [Same Error]
  2. pip uninstall opencv-python-headless -> [Other Error]
  3. pip uninstall opencv-python; pip install opencv-python -> [Solved]

Thank you, @hg2051

from opencv-python.

hg2051 avatar hg2051 commented on July 19, 2024 96

It's because of ''opencv-python-headless'. Uninstall it!

from opencv-python.

TracyLoza avatar TracyLoza commented on July 19, 2024 22

I have the same problem too. I did pip uninstall opencv-python-headless and it still does not work.

Same to me, but I do this:
pip uninstall opencv-python
Then:
pip install opencv-python

from opencv-python.

Yuvaldavid avatar Yuvaldavid commented on July 19, 2024 12

I have the same problem too. I did pip uninstall opencv-python-headless and it still does not work.

from opencv-python.

Kitty1122 avatar Kitty1122 commented on July 19, 2024 8

Tried pip uninstall opencv-python-headless - didn't work
Also, pip uninstall opencv-python; pip install open-python - didn't work

Closed Spyder environment and opened it again - worked! :)

from opencv-python.

Mayur8991 avatar Mayur8991 commented on July 19, 2024 4

ya it is because of pip install OpenCV- python- headless just uninstall it and your error will be sorted

from opencv-python.

obensustam2 avatar obensustam2 commented on July 19, 2024 3

Please use Pycharm, it is way easier to manage the packages

from opencv-python.

bkaan99 avatar bkaan99 commented on July 19, 2024 2

Solve: Unistall opencv-python-headless

from opencv-python.

bkaan99 avatar bkaan99 commented on July 19, 2024 2

@LikhithChakravarthi Hi Addinational Solution :
Use Pycharm,
Install opencv-python and cv2 from the module installation location of the interpreter you will use from the interpreter options in Pycharm.

from opencv-python.

venkat1230 avatar venkat1230 commented on July 19, 2024 2

Hay
please try to update the --> { python -m pip install opencv-python --upgrade } <-- in windows
it worked for me.

from opencv-python.

Sellouk avatar Sellouk commented on July 19, 2024 2

The error you're encountering indicates that the version of OpenCV you're using was built without GUI support for window management. To resolve this issue and display the camera feed in a window, you can either rebuild OpenCV with GUI support or use an alternative library to display the camera feed. Here are two possible solutions:

Solution 1: Rebuild OpenCV with GUI Support (Recommended)

Ensure you have CMake installed on your system.

Rebuild OpenCV with GUI support using CMake. You can do this by following these steps:

Download the OpenCV source code from the official OpenCV website: https://opencv.org/releases/

Extract the downloaded source code archive to a directory.

Open a terminal or command prompt and navigate to the directory where you extracted the OpenCV source code.

Create a build directory within the OpenCV source directory and navigate to it:
Configure the build using CMake with GUI support enabled:
using :
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=ON -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

After successful configuration, build and install OpenCV:
make
sudo make install

Once the installation is complete, you should have OpenCV with GUI support.

Update your Python environment to use the newly built OpenCV library. You may need to uninstall the previous OpenCV package and install the new one.

from opencv-python.

skvark avatar skvark commented on July 19, 2024

Duplicate of #17

from opencv-python.

hprasad98 avatar hprasad98 commented on July 19, 2024

getting same error
please help..
in-advance thank you

from opencv-python.

dwaynemcfarlane avatar dwaynemcfarlane commented on July 19, 2024

uninstalled opencv-python-headless and still the same error. I am using Ubuntu.

from opencv-python.

LikhithChakravarthi avatar LikhithChakravarthi commented on July 19, 2024

I have tried everything, unistalling opencv-python, contrib modules and reinstalling them and Uninstalling headless module, but not working. Can ayone help me?

from opencv-python.

Lelouch2503 avatar Lelouch2503 commented on July 19, 2024

Hay please try to update the --> { python -m pip install opencv-python --upgrade } <-- in windows it worked for me.

Thanks, it worked for me too=)))

from opencv-python.

vivekmorariya avatar vivekmorariya commented on July 19, 2024

if you are using spyder then ...
uninstall the open cv which you have installed by command prompt or anaconda prompt
then install the opencv library using the terminal available in the spyder itself
then try again to run the same code/program using spyder it will run.

from opencv-python.

VanshRana12 avatar VanshRana12 commented on July 19, 2024

The error you're encountering indicates that the version of OpenCV you're using was built without GUI support for window management. To resolve this issue and display the camera feed in a window, you can either rebuild OpenCV with GUI support or use an alternative library to display the camera feed. Here are two possible solutions:

Solution 1: Rebuild OpenCV with GUI Support (Recommended)

Ensure you have CMake installed on your system.

Rebuild OpenCV with GUI support using CMake. You can do this by following these steps:

Download the OpenCV source code from the official OpenCV website: https://opencv.org/releases/

Extract the downloaded source code archive to a directory.

Open a terminal or command prompt and navigate to the directory where you extracted the OpenCV source code.

Create a build directory within the OpenCV source directory and navigate to it: Configure the build using CMake with GUI support enabled: using : cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=ON -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..

After successful configuration, build and install OpenCV: make sudo make install

Once the installation is complete, you should have OpenCV with GUI support.

Update your Python environment to use the newly built OpenCV library. You may need to uninstall the previous OpenCV package and install the new one.

To do this but for windows:
After running this command successfully:
"cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_opencv_python2=OFF -D BUILD_opencv_python3=ON -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON .."

Instead of executing "make" and "sudo make install" as these are bash commands,
In powershell you have to execute these commands in the build directory:
To Build: cmake --build . --config Release
To Install: cmake --build . --target INSTALL

Now uninstall and then reinstall "opencv-python" using pip.

Done!

from opencv-python.

tegarpf90 avatar tegarpf90 commented on July 19, 2024

pip uninstall opencv-python; pip install opencv-python Solved by pycharm

from opencv-python.

hzx829 avatar hzx829 commented on July 19, 2024

On Ubuntu, this work for me:

sudo apt-get install python3-opencv

from opencv-python.

oussamaJMAA avatar oussamaJMAA commented on July 19, 2024

Hay please try to update the --> { python -m pip install opencv-python --upgrade } <-- in windows it worked for me.

ugprading to a newer version solved the issue for me ( opencv 4.9.0)

from opencv-python.

DAVID-Hown avatar DAVID-Hown commented on July 19, 2024

@skvark
@hzx829
@nofreewill42
@hzx829

# apt install libgtk2.0-dev pkg-config
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libgl1-mesa-glx : Depends: libgl1 but it is not going to be installed
                   Depends: libglx-mesa0 but it is not going to be installed
 libgtk2.0-dev : Depends: libgtk2.0-0 (= 2.24.32-4ubuntu4) but it is not going to be installed
                 Depends: gir1.2-gtk-2.0 (= 2.24.32-4ubuntu4) but it is not going to be installed
                 Depends: libgtk2.0-common but it is not going to be installed
                 Depends: libglib2.0-dev (>= 2.27.3) but it is not going to be installed
                 Depends: libgdk-pixbuf2.0-dev (>= 2.21.0) but it is not going to be installed
                 Depends: libpango1.0-dev (>= 1.20) but it is not going to be installed
                 Depends: libatk1.0-dev (>= 1.29.2) but it is not going to be installed
                 Depends: libcairo2-dev (>= 1.6.4-6.1) but it is not going to be installed
                 Depends: libx11-dev (>= 2:1.0.0-6) but it is not going to be installed
                 Depends: libxext-dev (>= 1:1.0.1-2) but it is not going to be installed
                 Depends: libxinerama-dev (>= 1:1.0.1-4.1) but it is not going to be installed
                 Depends: libxi-dev (>= 1:1.0.1-4) but it is not going to be installed
                 Depends: libxrandr-dev (>= 2:1.2.99) but it is not going to be installed
                 Depends: libxcursor-dev but it is not going to be installed
                 Depends: libxfixes-dev (>= 1:3.0.0-3) but it is not going to be installed
                 Depends: libxcomposite-dev (>= 1:0.2.0-3) but it is not going to be installed
                 Depends: libxdamage-dev (>= 1:1.0.1-3) but it is not going to be installed
                 Depends: libxml2-utils but it is not going to be installed
                 Recommends: debhelper but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/usr/local/lib/python3.8/dist-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.
import cv2
image = cv2.imread("1.jpg")
cv2.imshow("image", image)
cv2.waitKey(0)
cv2.destroyAllWindows()

When I connect to the server remotely using pycharm, I want a local visualization
I have encountered this problem, I would like to ask you how to solve it?

https://stackoverflow.com/questions/64784315/qt-qpa-xcb-could-not-connect-to-displayerror-while-using-opencv-on-ec2-ubuntu-s: In my past experience, pycharm can do local visualization, but sometimes it will go wrong, is this related to the pycharm version or is it related to the remote server

from opencv-python.

jmhasan1 avatar jmhasan1 commented on July 19, 2024

It's because of ''opencv-python-headless'. Uninstall it!

Hie , I have uninstall opencv-headless but upon uninstalling that I am unable to import opencv
ModuleNotFoundError: No module named 'cv2'
(upon uninstalling opencv-headless)
And if I reinstall opencv (with opencv-headless) , it is imported but stuck in same error

from opencv-python.

c2727c avatar c2727c commented on July 19, 2024

Did uninstall then re-install opencv-python and it worked for me.

before:

  • opencv-python==4.8.0.74
  • opencv-python-headless==4.9.0.80
    after:
    - opencv-python==4.9.0.80
    - opencv-python-headless==4.9.0.80

So I guess this error can be caused by mismatched versions of opencv-python and opencv-python-headless.

from opencv-python.

dineth88 avatar dineth88 commented on July 19, 2024

If you are using Pycharm, just simply change the interpreter and try to run your application again. It solves my problem relating with this error.

from opencv-python.

haileyesus34 avatar haileyesus34 commented on July 19, 2024

Uninstalling the opencv-python and then reinstalling it worked for me

from opencv-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.