ubuntu16 install opencv to interact with python

1. Local environment
I have python2.7 and 3.5 in my ubuntu, and then install python3.6 when installing anaconda3.
Opencv3.2 has been installed on the computer before, and the C++ compiler can be included, but the python compiler cannot be imported.
Look at this explanation: https://blog.csdn.net/wd1603926823/article/details/79445000 may be because several options were not selected when compiling and installing.
Since the previous opencv was before I installed anaconda3, the location of the installed library files was not under the management of anaconda. For unified management, I decided to install openc3.4 with python interface
. Installation steps
1. First check whether numpy is installed and then download the file whl Download
wget -c https://files.pythonhosted.org/packages/d0/ee/fb76784459b35c55740a0b20c7cfbd06752f9f8f96bf0bdcfafe2e8cf363/opencv_contrib_python-3.4.0.12-cp36-cp36m-manylinux1_x86_64.whl
2. pip install whl文件存放地址
in python3.6 / site- In packages/cv2, you can see the cv2.cpython-36m-x86_64-linux-gnu.so file, which means the installation is successful
3. Test
Open the python environment, enter import cv2, and no error is reported.
4. Problems
Although import cv2 does not report an error, the function of cv2 in pycharm will prompt that it cannot be found. Then I click "+" in pycharm-settings-project interpret, search for opencv, and install the specified version. Although an error was reported at the end, it can be used normally.

Broken thoughts: After using anaconda management, if I install directly without creating a virtual environment, the installed packages are all placed in anaconda/lib/python3.6/site-packages, so when pycharm chooses the python interpreter, choose anaconda/ bin/python

Official website installation method: https://docs.opencv.org/3.4/d2/de6/tutorial_py_setup_in_ubuntu.html

Guess you like

Origin blog.csdn.net/qq_43265072/article/details/106752921