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
  • 1
    Possible duplicate of [ImportError: numpy.core.multiarray failed to import](https://stackoverflow.com/questions/20518632/importerror-numpy-core-multiarray-failed-to-import) – Agile_Eagle Nov 14 '18 at 17:17
  • After following the solution from the aforementioned problem, my error still persisted – acceptablesimple7 Nov 14 '18 at 17:30
  • Please can you check what versions of numpy you are using following the instructions here https://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! – Rob Bricheno Nov 14 '18 at 18:14
  • I just updated the post based on what you suggested – acceptablesimple7 Nov 15 '18 at 00: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. – ZdaR Nov 15 '18 at 05:43
  • Please refer to this [blog](https://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/) for installing OpenCV. – ZdaR Nov 15 '18 at 05:43
  • It appears that the problem is in fact related to the numpy libraries. The architecture of the Jetson seems to give problems like these every once in a while. – acceptablesimple7 Nov 21 '18 at 00:23

0 Answers0