Accidentally removing the built-in Opencv

Hi there!

I think the Xavier Jetson AGX comes with a built in opencv, and i did a

sudo apt-get install python-opencv

which seemed to removed the current ‘libopencv-python’ package.

Now, I can’t run my code ("No module named ‘cv2’). I’m wondering if there’s any chance i can recover it…

Thank you!

Code base as below

sudo apt-get install python-opencv
[sudo] password for gabriel: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  gdal-data libarmadillo8 libarpack2 libcharls1 libdap25 libdapclient6v5
  libepsilon1 libfreexl1 libfyba0 libgdal20 libgdcm2.8 libgeos-3.6.2
  libgeos-c1v5 libgeotiff2 libgif7 libgl2ps1.4 libhdf4-0-alt
  libhdf5-openmpi-100 libkmlbase1 libkmldom1 libkmlengine1 liblept5
  libminizip1 libnetcdf-c++4 libnetcdf13 libodbc1 libogdi3.2
  libopencv-calib3d3.2 libopencv-contrib3.2 libopencv-core3.2
  libopencv-features2d3.2 libopencv-flann3.2 libopencv-highgui3.2
  libopencv-imgcodecs3.2 libopencv-imgproc3.2 libopencv-ml3.2
  libopencv-objdetect3.2 libopencv-photo3.2 libopencv-shape3.2
  libopencv-stitching3.2 libopencv-superres3.2 libopencv-video3.2
  libopencv-videoio3.2 libopencv-videostab3.2 libopencv-viz3.2 libpq5
  libproj12 libpython-stdlib libqhull7 libsocket++1 libspatialite7 libsuperlu5
  libtesseract4 liburiparser1 libvtk6.3 libxerces-c3.2 odbcinst
  odbcinst1debian2 proj-bin proj-data python python-minimal python-numpy
  python2.7 python2.7-minimal
Suggested packages:
  geotiff-bin gdal-bin libgeotiff-epsg libhdf4-doc libhdf4-alt-dev hdf4-tools
  libmyodbc odbc-postgresql tdsodbc unixodbc-bin ogdi-bin mpi-default-bin
  vtk6-doc vtk6-examples python-doc python-tk python-dev python-nose
  python-numpy-dbg python-numpy-doc python2.7-doc binfmt-support
The following packages will be REMOVED:
  libopencv-python
The following NEW packages will be installed:
  gdal-data libarmadillo8 libarpack2 libcharls1 libdap25 libdapclient6v5
  libepsilon1 libfreexl1 libfyba0 libgdal20 libgdcm2.8 libgeos-3.6.2
  libgeos-c1v5 libgeotiff2 libgif7 libgl2ps1.4 libhdf4-0-alt
  libhdf5-openmpi-100 libkmlbase1 libkmldom1 libkmlengine1 liblept5
  libminizip1 libnetcdf-c++4 libnetcdf13 libodbc1 libogdi3.2
  libopencv-calib3d3.2 libopencv-contrib3.2 libopencv-core3.2
  libopencv-features2d3.2 libopencv-flann3.2 libopencv-highgui3.2
  libopencv-imgcodecs3.2 libopencv-imgproc3.2 libopencv-ml3.2
  libopencv-objdetect3.2 libopencv-photo3.2 libopencv-shape3.2
  libopencv-stitching3.2 libopencv-superres3.2 libopencv-video3.2
  libopencv-videoio3.2 libopencv-videostab3.2 libopencv-viz3.2 libpq5
  libproj12 libpython-stdlib libqhull7 libsocket++1 libspatialite7 libsuperlu5
  libtesseract4 liburiparser1 libvtk6.3 libxerces-c3.2 odbcinst
  odbcinst1debian2 proj-bin proj-data python python-minimal python-numpy
  python-opencv python2.7 python2.7-minimal
0 upgraded, 66 newly installed, 1 to remove and 0 not upgraded.
Need to get 51.8 MB/54.9 MB of archives.
After this operation, 254 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

And the error…

Traceback (most recent call last):
  File "test.py", line 18, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'

While, after installing opencv, i seem to have a newer version here.

gabriel@gabriel-desktop:~$ pkg-config --modversion opencv
3.3.1

Why you cannot just install it back again by using “sudo apt-get install python-opencv”?

Or you could just use sdkmanager to install sdk only.