Install OpenCV in Ubuntu 20.04 not working

asked 2020-08-19 23:20:40 -0600

updated 2020-08-20 03:34:21 -0600

berak gravatar image

Hello,

I have done the following to install Open CV in Ubuntu 20.04

sudo apt update
sudo apt install libopencv-dev python3-opencv

I get following output on the CLI

sudo apt-get install python3-opencv
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  python3-opencv
0 to upgrade, 1 to newly install, 0 to remove and 7 not to upgrade.
Need to get 1,214 kB of archives.
After this operation, 7,008 kB of additional disk space will be used.
Get:1 http://au.archive.ubuntu.com/ubuntu focal/universe amd64 python3-opencv amd64 4.2.0+dfsg-5 [1,214 kB]
Fetched 1,214 kB in 1s (1,076 kB/s)      
Selecting previously unselected package python3-opencv.
(Reading database ... 198752 files and directories currently installed.)
Preparing to unpack .../python3-opencv_4.2.0+dfsg-5_amd64.deb ...
Unpacking python3-opencv (4.2.0+dfsg-5) ...
Setting up python3-opencv (4.2.0+dfsg-5)

However, when I execute ipython, and type "import c.." (then hit tab to auto complete)...

python3
Python 3.7.6 (default, Jan  8 2020, 19:59:22) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import c
callable(     chr(          class         classmethod(  compile(      complex(      continue      copyright(    credits(

There is no cv2 module. I have read a few web posts from others, and I am not running a virtual environment...I have tried to uninstall and reinstall..no effect

any help is welcome

Cheers

edit retag flag offensive close merge delete

Comments

python3-opencv

opencv does not maintain this

import c

what are you trying to do here ? (i don't even have a "c" module)

  • try to find out, if there are more than one python version installed (no idea, but ipython might come with its own)
  • try to run code from a simple cmdline, not from a notebook
berak gravatar imageberak ( 2020-08-20 01:36:55 -0600 )edit
1

Hello Berak,

So I executed using ipython and python3 from CLI, same output (which is did not find cv2 module).

Cheers

Colombian1976 gravatar imageColombian1976 ( 2020-08-20 06:34:42 -0600 )edit

import cv2 is mandatory

berak gravatar imageberak ( 2020-08-20 08:39:13 -0600 )edit