3

I am unable to import cv2 on either python2 or python3

when I call in python2 I get the following error

ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import

and when I call in python3

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/local/lib/python3.5/dist-packages/cv2.so: undefined 
symbol: PyCObject_Type

I know it has something to do with the path and When I use the >>> print(sys.path) I get the following

['', '/home/nvidia/Downloads', '/usr/local/lib', 
'/usr/local/lib/python3.5/dist-packages', '/usr/local/lib/cv2.po', 
'//home/nvidia/src/opencv-3.4.2/build/lib/cv2.so', 
'/home/nvidia/src/opencv-3.4.2/build/lib/cv2.so', 
'/usr/local/lib/python3.5/dist-packages/cv2.so', 
'/usr/lib/python35.zip', '/usr/lib/python3.5', 
'/usr/lib/python3.5/plat-aarch64-linux-gnu', '/usr/lib/python3.5/lib- 
dynload', '/usr/lib/python3/dist-packages']

I'm certain I have to remove some of the above paths but I do no want to risk anything without being sure. For the record I am using the Jetson TX2

Edit: attempted to fix the problem by updating numpy but the error persisted

Edit#2: These are the versions of numpy that I currently have install

python -c "import numpy; print(numpy.version.version)" 1.15.4


python3 -c "import numpy; print(numpy.version.version)" 1.15.4
7
  • 1
    Possible duplicate of ImportError: numpy.core.multiarray failed to import Commented Nov 14, 2018 at 17:17
  • After following the solution from the aforementioned problem, my error still persisted Commented Nov 14, 2018 at 17:30
  • Please can you check what versions of numpy you are using following the instructions here stackoverflow.com/a/1520264/9794932 and edit this into your post. For both python 2 and python 3, and tell us which is which. Thanks! Commented Nov 14, 2018 at 18:14
  • I just updated the post based on what you suggested Commented Nov 15, 2018 at 0:11
  • It seems that you have two different problems. Firstly you have installed OpenCV for Python2 successfully, but the numpy libraries were not found while installation. Secondly, You haven't installed OpenCV for Pyhton3, hence the cv2.so not found error. While installing OpenCV you have to specify the Python version you want to install the library for. It does not gets installed for both version simultaneoulsy. I think you have followed the instructions for installing OpenCV on Python2 but missed the numpy step. Commented Nov 15, 2018 at 5:43

0

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.