OpenCV not working properly with python on Linux with anaconda. Getting error that cv2.imshow() is not implemented
1.The easiest way:
conda remove opencv
conda update conda
conda install --channel menpo opencv
or (for OpenCV 3.1) :
conda install -c menpo opencv3
2.And if u don't want to do this, you can try to use matplotlib .
import cv2
import matplotlib.pyplot as plt
img = cv2.imread('img.jpg',0)
plt.imshow(img, cmap='gray')
plt.show()
3.Or try to build library by your own with option WITH_GTK=ON
, or smth like that.
Update - 18th Jun 2019
I got this error on my Ubuntu(18.04.1 LTS) system for openCV 3.4.2, as the method call to cv2.imshow was failing. I am using anaconda. Just the below 2 steps helped me resolve:
conda remove opencv
conda install -c conda-forge opencv=4.1.0
If you are using pip, you can try
pip install opencv-contrib-python
I have had to deal with this issue a couple of times, this is what has worked consistently thus far:
conda remove opencv
conda install -c menpo opencv
pip install --upgrade pip
pip install opencv-contrib-python
🚀 Working method (👨🔬 tested on April 19, 2019)
- 🐞 These error happen because of conda.
- 🏹 Open Anaconda Prompt and remove conda opencv if installed
- 👨💻
conda remove opencv
📢 If you have conda env, firstly activate it
conda activate <your_env_name>
- ⏬ After install opencv via pip (click here to offical info)
- 👨💻
pip install opencv-contrib-python
📢 if pip haven't installed, use
conda install pip
command.
If you installed OpenCV using the opencv-python pip package at any point in time, be aware of the following note, taken from https://pypi.python.org/pypi/opencv-python
IMPORTANT NOTE MacOS and Linux wheels have currently some limitations:
- video related functionality is not supported (not compiled with FFmpeg)
- for example
cv2.imshow()
will not work (not compiled with GTK+ 2.x or Carbon support)
Also note that to install from another source, first you must remove the opencv-python package