0

I want to import opencv in spyder using the IPython console. However, when I try to do this, I get an import error on numpy.

Platform: Jetson xavier Spyder version: 3.2.6 I'm using 'virtualenv' to manage my virtual environment.

What works: I can import cv2 in python using a bash terminal. Steps to reproduce:

  1. Activate my virtual environment by running source my_env/bin/activate
  2. Start python by running python
  3. Import opencv by running import cv2
  4. Success

I use spyder as my IDE and I want to import opencv in a python script run by spyder. However, when I run import cv2 I get ImportError: numpy.core.multiarray failed to import. Steps to reproduce:

  1. In spyder in preferences set the Python interpreter to the one from my virtual environment (~/my_env/bin/python3)
  2. Restart IPython console
  3. Type import cv2 in the IPython console
  4. I get the ImportError: numpy.core.multiarray failed to import

I already tried updating numpy, as recommended by ImportError: numpy.core.multiarray failed to import but this did not work.

Update In spyder I can import numpy manually, and using inspect.getfile(numpy) tells me that spyder imported numpy from /usr/lib/python3/dist-packages/numpy/__init__.py, While it sohuld import numpy from ~/my_env/lib/python3.6/site-packages/numpy. Why is spyder importing numpy from the wrong environment?

Thijs Ruigrok
  • 547
  • 2
  • 12
  • (*Spyder maintainer here*) Spyder 3.2.6 is more than three years old. Please install our latest version (5.2.1) and try again. – Carlos Cordoba Dec 15 '21 at 19:53
  • @CarlosCordoba, tnx for your effort. Installing Spyder 5 did not work our for me. The Jetson is a has an aarch64 architecture, which is not supported by anaconda. Therefore the official Spyder5 package cannot be directly installed on the Jetson. Installing Spyder using pip also does not work out. However, Spyder 3 can be easily installed using apt-get. Do you know if there is a procedure to install Spyder5 on an aarch64 system? – Thijs Ruigrok Jan 03 '22 at 12:51

0 Answers0