1 Install cv2 in Ubuntu
Common errors:
python
import cv2
Error: ModuleNotFoundError: No module named 'cv2'
In general, the default installed version is lower, and the lower version is not compatible with the higher version, so I guess it is a problem with the opencv version , my python3.6. Download the corresponding opencv offline package according to the official website (preferably placed in the following directory)
opencv_python-3.4.6.27-cp36-cp36m-manylinux1_x86_64.whl
Then install:
pip3 install opencv_python-3.4.6.27-cp36-cp36m-manylinux1_x86_64.whl
Displayed after installation is complete
Successfully installed opencv-python-3.4.6.27
Test verification:
2 Docker container install cv2
To follow the cat and draw the tiger, we only need to send the installation package we downloaded in ubantu to the corresponding container, and repeat the above process.
lab@lab-virtual-machine:~/oai-cn5g-fed/docker-compose$ docker cp /home/lab/Downloads/opencv_python-3.4.6.27-cp36-cp36m-manylinux1_x86_64.whl bc0dabf8aaf9:/ueransim/bin
WARNING: Error loading config file: /home/lab/.docker/config.json: open /home/lab/.docker/config.json: permission denied
Preparing to copy...
Then install it in the corresponding directory of the container:
Running the python3 script reports an error:
2.1 Error resolution
After installing opencv under the docker virtual machine, the following error occurs when using it
Traceback (most recent call last):
File "data_generator.py", line 24, in <module>
import cv2
File "/usr/local/lib/python3.5/dist-packages/cv2/__init__.py", line 3, in <module>
from .cv2 import *
ImportError: libSM.so.6: cannot open shared object file: No such file or directory
Refer to Ubuntu's apt-file to solve dependency problems_ubuntu apt dependency_SnailTyan's Blog-CSDN Blog
Install apt-file first
# Install
$ apt-get update
$ apt-get install apt-file
# Update apt-file
$ apt-file update
Then look for the dependent library:
apt-file search libSM.so.6
Follow the prompts to install the appropriate dependency library:
apt-get install libsm6
problem solved