5

I just ran the script to install OpenCV. I'm running Linux here. I installed it after much struggle but it finally has completed. That being said, for some reason, it still isn't working. I've never had this much trouble installing a package in my life. Here are the last few lines of my terminal:

**********************************************************************

 Done. The new package has been installed and saved to

 /home/myname/Desktop/OpenCV/opencv-2.4.9/build/build_20140812-1_i386.deb

 You can remove it from your system anytime using: 

      dpkg -r build

**********************************************************************

OpenCV 2.4.9 ready to be used
me:~/Desktop$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] 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

anyone have any ideas why it's not working? thanks

5
  • Is your module on python path? Commented Aug 12, 2014 at 14:06
  • not sure, I'm not very knowledgeable with that kind of stuff Commented Aug 12, 2014 at 14:07
  • If you have more than one Python version installed check the package was installed in the one you are running. Commented Aug 12, 2014 at 14:07
  • How do you install the package? Commented Aug 12, 2014 at 14:12
  • I think your problem is similar to what mention here .Hope this will solve your problem Commented Aug 12, 2014 at 14:13

1 Answer 1

10

From openCV - python installation manual:

After installing:

Installation is over. All files are installed in /usr/local/ folder. But to use it, your Python should be able to find OpenCV module. You have two options for that. Move the module to any folder in Python Path : Python path can be found out by

entering import sys;print sys.path in Python terminal. It will print out many locations. Move /usr/local/lib/python2.7/site-packages/cv2.so to any of this folder. For example,

    su mv /usr/local/lib/python2.7/site-packages/cv2.so /usr/lib/python2.7/site-packages

But you will have to do this every time you install OpenCV.

Add /usr/local/lib/python2.7/site-packages to the PYTHON_PATH: It is to be done only once. Just open ~/.bashrc and add following line to it, then log out and come back.

    export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages

Thus OpenCV installation is finished. Open a terminal and try import cv2.

Note that your python version or library location may be different.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.