Today I installed opencv 2.4.4 to Ubuntu 12.10
But import cv2 not works.
root@-:~# python
Python 2.7.3 (default, Sep 26 2012, 21:53:58)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>>
As I understand cv2.so missed, so python don't see where opencv
root@-:~# find / -name "cv.py"
/root/opencv-2.4.4/modules/python/src2/cv.py
root@-:~# find / -name "cv2.so"
root@-:~#
My setup steps look like
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.4/OpenCV-2.4.4a.tar.bz2
tar -xjf OpenCV-2.4.4a.tar.bz2
cd opencv-2.4.4
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
make && make install
echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf
ldconfig
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig" >> /etc/bash.bashrc
echo "export PKG_CONFIG_PATH" >> /etc/bash.bashrc
Where is cv2.so ? And why it was missed ?
I have this problem in my OS X El Capitan.
I followed the instructions mentioned in this tutorial. Didn't get a successful working install and had the above error of missing cv2.so file in the required folders mentioned and at the
python
prompt.Finally figured that using the virtual python setup was causing trouble. So uninstalled with
Then ran
which threw errors.
And then followed below steps to resolve the issue.
First run
If it gives an error, try for an automated diagnosis
brew doctor
gives a list of problems that could be leading to errors in installation process.To fix problems in case of conflicting files, run to get a list of all actions which will be performed by overwrite without actually performing them.
To list all files that would be deleted:
followed by this run which will execute the overwrite, assuming you feel that the actions performed by overwrite will take your system to a more stable state.
To force the link and overwrite all conflicting files:
This tutorial is a simpler alternative.
All above answers did not work for me, however, after a whole day struggling, I finally solved this problem.
To have cv2.so, we need:
To tell camke where the path is, just take my command as an example:
for python3,you should (I'm using anaconda python, so I linked everything to anaconda):
One thing to remember!!! before you enter cmake ... 1. clean your build folder, 2. Only camke once! otherwise you can not change ** PYTHON3_LIBRARY: NO**...(this is a bug I think)
I know there might be some useless arguments, but I am tired to try to clean them. Here's a screenshot of my cmake print info. screenshot of my cmake info
You can clearly see that, only python2 can generate cv2.so. python3 can not! (Python3 wrappers can not be generated).
None of the above worked for me; am in Ubuntu 16.04 on an ec2 instance & had anaconda installed so I just used
conda install opencv
for both my conda2 and 3 installsin my case it was a problem with cmake
sudo apt-get install software-properties-common sudo add-apt-repository ppa:george-edison55/cmake-3.x sudo apt-get update
If cmake is not yet installed:
sudo apt-get install cmake
If cmake is already installed: ' sudo apt-get upgrade `
for more information
I install
python-opencv
to solve my problem in Ubuntu 14.04sh sudo apt-get install python-opencv
I came across similar problem. After digging into this a little more I came across a post where it was mentioned that
python-numpy
package was required. So, I uninstalled the opencv by running the following command in build folder(in your case release folder):Then I removed all the opencv files. I installed
python-numpy
andpython-dev
with this command:Then, after re-running the installation script,
import cv2
command in python console doesn't give me any error and is properly imported.