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:
- Activate my virtual environment by running source my_env/bin/activate
- Start python by running python
- Import opencv by running import cv2
- 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:
- In spyder in preferencesset thePython interpreterto the one from my virtual environment (~/my_env/bin/python3)
- Restart IPython console
- Type import cv2in the IPython console
- 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?
