I used the following command to know the numpy version I am using
pip show numpy
output shown below
---
Name: numpy
Version: 1.8.2
Location: /usr/lib/python2.7/dist-packages
Requires:
However when I am running matplotlib, I got a error as
RuntimeError: module compiled against API version a but this version of numpy is 9
from matplotlib import pyplot as plt
File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/usr/local/lib/python2.7/dist-packages/matplotlib/colorbar.py", line 32, in <module>
import matplotlib.artist as martist
File "/usr/local/lib/python2.7/dist-packages/matplotlib/artist.py", line 12, in <module>
from .transforms import Bbox, IdentityTransform, TransformedBbox, \
File "/usr/local/lib/python2.7/dist-packages/matplotlib/transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
I tried to upgrade numpy,
pip install numpy --upgrade
it shows to be installed successfully, but numpy still shows to be 1.8.2 and error continues to exist when running matplotlib.
I thought to uninstall numpy and reinstall it, the system gives the message saying
Not uninstalling numpy at /usr/lib/python2.7/dist-packages, owned by OS
how to solve it ?
any idea about
RuntimeError: module compiled against API version a but this version
of numpy is 9
How can I upgrade numpy? might be working for you. IN that case it was a path problem:
RuntimeError: module compiled against API version 9 but this version of numpy is 6
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import
Solution:
Check the path
import numpy
print numpy.__path__
and manually delete it using rm
I also had the same problem until I came across this Issue on Pytorch github repository. This command worked perfectly for me:
pip install numpy -I
It is also mentioned there that pip install numpy --upgrade is not working(don't know why). You can check the above mentioned link.
I had a similar problem with numpy when running torch. I tried uninstalling numpy and installing it using -U but it didn't work. After some search, I found this link and it solved my problem. It says you should change your numpy version.
pip uninstall numpy
pip install numpy==1.19.3
The answer is probably simple.
Just add
import numpy.core.multiarray
before the
import cv2
statement.
It worked fine for me.
My problem is solved using the old version of numpy. The solution is to use numpy 1.19.3.
pip install numpy==1.19.3
Credit: https://stackoverflow.com/a/64730012
Installing the previous version of NumPy, 1.19.3 should fix this.
python -m pip install numpy==1.19.3
Related
I am having issues with the numpy library. I am trying to code a webcam using the opencv library, but I am getting this issue:
OpenCV bindings requires "numpy" package.
Install it via command:
pip install numpy
Traceback (most recent call last):
File "/home/pi/Documents/security-camera/take_picture.py", line 1, in <module>
import cv2
File "/home/pi/.local/lib/python3.9/site-packages/cv2/__init__.py", line 12, in <module>
import numpy.core.multiarray
ModuleNotFoundError: No module named 'numpy.core.multiarray'
When I try to install numpy using pip, I get this error:
pi#raspberrypi:~/Documents/security-camera $ python3 -m pip install numpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (1.19.5)
It says I already have the numpy library, even though when I run it says to install it. Does anyone know how to fix it?
I figured out how to solve this issue: I was getting an issue with numpy earlier and was trying to reinstall it, so I deleted the numpy folder in /usr/lib/python3/dist-packages, then I tried to install it again but it did not work. Then I got this issue. There are actually two numpy folders in /usr/lib/python3/dist-packages, so when I deleted the one with the python files in it, and imported numpy in the python program, it says numpy did not exist, but when I tried to reinstall numpy with pip, it said it already existed because it looked at the other folder. So what I had to do was delete the other folder in /usr/lib/python3/dist-packages, and then reinstalling numpy worked.
I installed skimage in ubuntu terminal using command:
sudo apt-get install python-skimage
it installed succesfully but when using it in my code (from skimage.filters import threshold_local). i get an error:
Traceback (most recent call last):
File "scan.py", line 4, in <module>
from skimage.filters import threshold_local
ImportError: No module named filters
kindly someone help me to correct this!
The problem is resolved now :D. What I found is that there is no module named 'filters' in skimage '0.10.1' as it has 'filter'. So, when I upgraded it using the command
sudo pip install --upgrade scikit-image
to version '0.13.1', it comes with the 'filters' module instead of 'filter'. The 'filters' module has all attributes of thresholding including 'local' and others as well.
So I got same problem in Spyder, Python 3.6.6.
this code (with img being a np array):
import skimage
val = skimage.filters.threshold_otsu(img)
gives: module 'skimage' has no attribute 'filters'
I tried pip install --upgrade scikit-image with no change. Skimage is indeed in my system path:
*'C:\WPy-3661\python-3.6.6.amd64\lib\site-packages', and the filters folder is in there with the init file.
but if i do:
from skimage import filters as anything
val = skimage.filters.threshold_otsu(img)
then it works. This is not normal, right ?
Note that in my sys.path paths there is only one skimage folder. So I don't think it's a duplicate issue.
I had also same problem but below code helped me:
!sudo apt-get install python-skimage
from skimage.filters import roberts, prewitt, sobel, scharr, laplace
While importing pandas I am getting below error:
>>> import pandas as pd
**RuntimeError: module compiled against API version 6 but this version of numpy is 4**
numpy.core.multiarray failed to import
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/site-packages/pandas/__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
ImportError: numpy.core.multiarray failed to import
Tried to upgrade numpy module to the latest version.
Getting below message:
[abc]# yum install numpy
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
**Package numpy-1.4.1-9.el6.x86_64 already installed and latest version**
Is there any manual work around to resolve this problem?
Well the module's answer to your import request seems to be pretty self-explaining. Did you try a
yum update numpy
If that doesn't fix your problem (I don't know what repos your centos distro uses) you could always try the pip approach
pip install -U numpy
If that still doesnt solve your problem, you might have several versions of numpy installed and your should try the answers to this question.
I want to install scipy packages and I know it's a repetitive question, but I have tried all of them but I didn't find a proper solution.
when write this : import scipy
it executes successfully. but when I try this:
import scipy.spatial
I receive this message:
Traceback (most recent call last):
File "C:/Users/Hamid/Documents/kodeyaro/kodefolani.py", line 41, in <module>
from scipy.spatial import Delaunay
File "C:\Python27\lib\site-packages\scipy\spatial\__init__.py", line 92, in module>
from .qhull import *
ImportError: DLL load failed: The specified module could not be found.
what should I do?
below re-installation will fix the issue as required dll will be placed at right place.
user should have admin permissions on the system.
python -m pip install scipy --upgrade --force
I faced this problem when I switched to python38. Build was failing while scipy installation.
I solved by using prebuilt libs from Prof: Gohlke
https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Install appropriate numpy+mkl version using --force argument
pip install numpy-1.17.3+mkl-cp38-cp38-win_amd64.whl --force
Run this in the cmd:
pip install scipy
It is advisable to run cmd as Adminstrator.
I have installed (with lots of troubles) scikits.audiolab for making sounds out of data. Now when I type:
import scikits.audiolab I get the following error
>>> import scikits.audiolab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/scikits.audiolab-0.11.0-py2.7-macosx-10.7-intel.egg/scikits/audiolab/__init__.py", line 25, in <module>
from pysndfile import formatinfo, sndfile
File "/Library/Python/2.7/site-packages/scikits.audiolab-0.11.0-py2.7-macosx-10.7-intel.egg/scikits/audiolab/pysndfile/__init__.py", line 1, in <module>
from _sndfile import Sndfile, Format, available_file_formats, \
File "numpy.pxd", line 30, in scikits.audiolab.pysndfile._sndfile (/private/tmp/easy_install-gKE3i5/scikits.audiolab-0.11.0/scikits/audiolab/pysndfile/_sndfile.c:9632)
ValueError: numpy.dtype does not appear to be the correct type object
How do I fix this?
Any alternative package that can do the job?
I had the same issue and for me it was caused by installing another (more recent) version of NumPy.
Check if you have different versions of NumPy installed and try switching back to an older one. For my part: I had a system-wide installation of Python and common modules like NumPy, which I couldn't touch because I'm not admin on that system. So when I installed some other library locally (in ~/.local/lib/python2.7/) it would also install more recent versions of SciPy and NumPy and put them into that local folder. And when importing the module it would draw from the local directory first before looking at the system-wide libraries which were working fine before with scikits.audiolab. So for me it was solved by
pip uninstall numy && pip uninstall scipy because that only deleted the newer local versions of numpy.
But more specific to your case, here is a tutorial how (on a Mac) to switch to a certain version of NumPy:
multiple numpy version on Mac OS X
The NumPy version I found working for my scikits.audiolab is 1.6.1
>>> import numpy
>>> numpy.version.version
'1.6.1'
Hope that helps. :)
Maybe you installed/upgraded numpy after installing talkbox. Try running this command:
pip install --upgrade --force-reinstall scikits.talkbox
As suggested here:
https://github.com/ppwwyyxx/speaker-recognition/issues/13