Ubuntu18.04-python2 installs the opencv4.1 version and replaces the low version of opencv that comes with ROS

Software Environment

  • Ubuntu 18.04 system
  • ROS melodic

View the CV2 location of the default installation of ROS

Insert picture description here

Change the name instead of cv2, just ok:
Insert picture description here

Check to remove

It can be found that there is also a cv2 so file, so we need to remove this as well.

Insert picture description here

Change the name, in case you need to use it in the future, it can be easily restored:

sudo mv /usr/lib/python2.7/dist-packages/cv2.x86_64-linux-gnu.so /usr/lib/python2.7/dist-packages/cv2.x86_64-linux-gnu.so.bak

It can be seen that there is no cv2 library now.
Insert picture description here

Install high version opencv-python

Installing opencv-python directly always reports an error inexplicably:
Insert picture description here

problem solved

The installed opencv-python version is too high, python2 does not support, just download the lower version:

 pip install opencv-python==4.1.1.26 

Insert picture description here

Successful installation!Insert picture description here

Reference article:

Guess you like

Origin blog.csdn.net/qq_45779334/article/details/114389148