Code:
import numpy as np import cv
Console:
>>> runfile('/Users/isaiahnields/.spyder2/temp.py', wdir='/Users/isaiahnields/.spyder2') RuntimeError: module compiled against API version a but this version of numpy is 9 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/spyderlib/widgets/externalshell/sitecustomize.py", line 685, in runfile execfile(filename, namespace) File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/spyderlib/widgets/externalshell/sitecustomize.py", line 78, in execfile builtins.execfile(filename, *where) File "/Users/isaiahnields/.spyder2/temp.py", line 9, in <module> import cv File "/Applications/Spyder-Py2.app/Contents/Resources/lib/python2.7/cv.py", line 1, in <module> from cv2.cv import * ImportError: numpy.core.multiarray failed to import >>>
System Info: OS X El Capitan, Macbook Air, 1.3 GHz Intel Core i5, 8 GB 1600 HMz DDR3
I have already attempted updating numpy. I had to add cv.py to the python2.7 folder in Spyder-Py2 is there something else I need to add?
How to check the Numpy version. To check a numpy version, write the numpy. __version__ code and run the file. It will return the current version of numpy installed on your machine.
NumPy 1.21. 0 (release notes) – 22 Jun 2021. NumPy 1.20. 3 (release notes) – 10 May 2021.
upgrade numpy to the latest version
pip install numpy --upgrade
Check the path
import numpy print numpy.__path__
For me this was /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy So I moved it to a temporary place
sudo mv /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy \ /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy_old
and then the next time I imported numpy the path was /Library/Python/2.7/site-packages/numpy/init.pyc and all was well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With