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.
Related
RasterIO appears to be a very promising library for geospatial IO and much easier for me to navigate than gdal's python bindings. I am having trouble installing it correctly.
Currently, I have am using pyenv and pyenv-virtualenv to manage python distributions and environments, respectively. I installed gdal with brew using the following steps.
I navigated to my project folder, activated the virtual environment and downloaded rasterio from PyPI: pip install rasterio. However, the only way to correctly import the package is to import osgeo first?!? I am concerned that this means I have some broken dependencies or I have installed rasterio incorrectly.
Specifically,
import osgeo
import rasterio
works fine (tested using with about half of their quickstart), but
import rasterio
does not. The latter producing:
Traceback (most recent call last):File "<string>", line 1, in <module>
File "/Users/home/.pyenv/versions/virtual_env_name/lib/python3.6/site-packages/rasterio/__init__.py", line 15, in <module>
from rasterio._base import (
ImportError: dlopen(/Users/home/.pyenv/versions/virtual_env_name/lib/python3.6/site-
packages/rasterio/_base.cpython-36m-darwin.so, 2): Symbol not found: _CPLMalloc
Referenced from: /Users/home/.pyenv/versions/virtual_env_name/lib/python3.6/site-packages/rasterio/_base.cpython-36m-darwin.so
Expected in: flat namespace in /Users/home/.pyenv/versions/virtual_env_name/lib/python3.6/site-packages/rasterio/_base.cpython-36m-darwin.so
Any suggestions on how to debug/interpret this error would be invaluable to me. Thanks!
If possible, I would prefer not build from source per these instructions.
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
I am trying to test scikit-learn library, but didn't manage to install it.
More details : I did install numpy, scipy, matplotlib and I can use them just fine. However, when I use pip (pip install -U scikit-learn), I get this error :
Partial import of sklearn during the build process.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\...\scikit-learn\setup.py", setup_package()
File "C:\Users\...\scikit-learn\setup.py", from numpy.distutils.core import setup
ImportError: No module named 'numpy'
I couldn't find anything about this.
I tried installing scikit-learn directly by using python setup.py and had the same problem. Any ideas?
Thanks you.
I think there are something wrong with the installation of numpy.
Try download and reinstall following package (for Python 2.7):
http://downloads.sourceforge.net/project/numpy/NumPy/1.9.2/numpy-1.9.2-win32-superpack-python2.7.exe?r=&ts=1442420256&use_mirror=netix
I am using Python 3.4.0. I am going to assume that the numpy module should work, as this is one of the newer versions of python. However, anything I do with numpy will result in a syntax error. Forexample this code here:
import numpy
list1=[1,3,2,6,9]
list2=numpy.mean(list1)
print(list2)
And then I get:
Traceback (most recent call last):
File "/home/yichen/Desktop/python/numpy test.py", line 1, in <module>
import numpy
ImportError: No module named 'numpy'
Is this just a problem with my computer or what?
It looks like numpy is not installed on your system. Assuming that you have the pip script installed with your python, you can perform following command to install it:
pip install numpy
or
pip3.4 install numpy
Or, depending on your distribution, it might come as a package named like python-numpy with your package manager.
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