Environment: ubuntu14.04 python2.7
Content: Installing and configuring OpenCV3.0
Today, according to the steps of the OPENCV online installation OpenCV But, after the Python prompt "No module named Cv2"
First, the steps to install OPENCV:
Installation steps of OPENCV official website: http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation
1. Download opencv:https://codeload.github.com/itseez/opencv/zip/3.0.0
2. Unzip:
1 tar -xzvf opencv3. 0.0
3. Install the required packages for OPENCV:
4. In the extracted OPCV directory, build a release directory, and then use CMake to compile the source code. (Use the official website method the last OpenCV installation directory is the release this directory)
1 cd ~/OpenCV2mkdir release3CD release4 Cmake-d cmake_build_type=release-d cmake_install_prefix=/usr/local. //There are two points behind here that can't be omitted, but what do you mean I don't understand
5. Then install
1 sudo make 2 sudo Make Install
At this point, the installation is complete.
Then, after the installation is complete, Python references the OpenCV "No module named Cv2" issue.
My main reference here is this blog post: http://pinkyjie.com/2010/10/19/ubuntu-opencv-python/
Here is a hint to the following place, the file "Cv.so" will appear during make, which is the key file to connect OpenCV and Python.
the "no module named Cv2" occurs because Python cannot find the cv.so file we just mentioned, we enter the path/usr/local/lib/ python2.7 found two folders, one is Dist-package, one is Site-package,python by default only in the former search, and we generated the cv.so file in our installation directory. /.. /opencv3.0.0/release "(Remember this directory, which is the directory we just built in the installation process, if you do not have this file in the installation directory, then the previous make step problem, may need to go through the entire installation process), All we need to do is simply move it to the Dist-package folder.
Finally, my test program:
1 Import Cv2 2 3 img = cv2.imread ('lena.jpg')4 cv2.imshow (' Image', img)5 k = cv2.waitkey (0)6
ubuntu14.04 python2.7 Installation Configuration OpenCV3.0