Quantcast
Channel: How to use opencv-python on WSL2 Ubuntu20.04 - Ask Ubuntu
Viewing all articles
Browse latest Browse all 2

How to use opencv-python on WSL2 Ubuntu20.04

$
0
0

I have just installed a Ubuntu-20.04 on WSL2. And I installed a miniconda env with python 3.7, and then I installed opencv-python by "conda install opencv". But when I try the simplest cv2.imshow, it complains below:

cv2.error: OpenCV(3.4.2) /tmp/build/80754af9/opencv-suite_1535558553474/work/modules/highgui/src/window.cpp:632: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvShowImage'

By the way, I can show plotting window by matplotlib.pyplot after I installed a VcXsrv and export DISPLAY=host_ip_in_wsl2:1.1. And I also make my GPU works after installed Windows 10 November 2021 update, CUDA driver for WSL2, and CUDA toolkit 11.0. I can get Tensorflow 2.4.1 working well with GPU. I can compile darknet with GPU and use it for YOLO v1.

I googled some. They say uninstall opencv and reinstall from channel menpo can do it. But this post is 5 years ago and not for WSL.

I also saw some posts demonstrate a tedious procedure to compile opencv-python from source.

So, how to use opencv-python on Ubuntu-20.04 of WSL2? Easy approaches like "conda install ..." or "pip install ..." is preferred. Compiling from source is also acceptable.


Viewing all articles
Browse latest Browse all 2

Trending Articles