Unable to import cv2

Question:

I tested the following command in python:

import cv2

I put it in the file b.py and run python b.py. But I met with the following error:

Traceback (most recent call last):
  File "b.py", line 1, in <module>
    import cv2
  File "/home/mypath/anaconda2/lib/python2.7/site-packages/cv2/__init__.py", line 9, in <module>
    from .cv2 import *
ImportError: libXdmcp.so.6: cannot open shared object file: No such file or directory

What’s wrong with this? Thank you all for helping me!

Asked By: pfc

||

Answers:

Did you install opencv correctly? Also what OS are you using (e.g. Windows, Linux OS X etc.)

If you’re using windows – did you follow these steps?:
http://docs.opencv.org/3.2.0/d5/de5/tutorial_py_setup_in_windows.html

If you are using Fedora install Opencv by typing this command into the terminal:

sudo yum install numpy opencv*

The cause of the problem may be that you haven’t installed the dependencies:

  • Matplotlib
  • Numpy

Hope this helps!

Answered By: Ben10
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.