ImportError: cannot import name NumpyTest - python

I am trying to read a *.wav file using scipy. I do it in the following way:
import scipy.io
x = scipy.io.wavfile.read('/usr/share/sounds/purple/receive.wav')
As a result I get the following error message:
Traceback (most recent call last):
File "test3.py", line 1, in <module>
import scipy.io
File "/usr/lib/python2.5/site-packages/scipy/io/__init__.py", line 23, in <module>
from numpy.testing import NumpyTest
ImportError: cannot import name NumpyTest
Does anybody know why scipy cannot import NumpyTest and how it can be fixed?

Looks like you have upgraded your numpy version but haven't installed a corresponding scipy version.

Do you have numpy installed? The package is most likely called numpy or python-numpy if you are running Linux
If your OS package manager does not have numpy package, download it from here

Related

why do I get an error with 'from scipy import random'?

I have installed scipy and getting the following back trace when importing the random module.
from scipy import random
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'random' from 'scipy' (/usr/local/lib/python3.10/dist-packages/scipy-1.9.1-py3.10-linux-x86_64.egg/scipy/__init__.py)
Did I miss something else to install?
In case of being relevant this is on ubuntu 22 with python 3.10.4.
scipy doesn't have random module which you can directly import anymore. as an alternative you can use random from numpy(scipy is built on numpy) like code below:
from numpy import random

Import Error : DLL module could not found, while importing pandas

I am working on Python 3.5 and I am importing Pandas, Numpy, scikit-learn and pickle libraries in pycharm IDE. I have installed all the libraries as well, via pycharm IDE's package installer. When i execute following commands it gives me no "Syntax" errors in IDE.
import pickle
from pathlib import Path
import numpy as np
import pandas as pd
from sklearn import metrics
from sklearn.cluster import KMeans
When i Execute my code it gives me following error for specifically importing "pandas" library. -->
Traceback (most recent call last):
File "D:/InputFile.py", line 5, in <module>
import pandas as pd
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\__init__.py", line 42, in <module>
from pandas.core.api import *
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\api.py", line 10, in <module>
from pandas.core.groupby.groupby import Grouper
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\groupby\__init__.py", line 2, in <module>
from pandas.core.groupby.groupby import (
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\groupby\groupby.py", line 49, in <module>
from pandas.core.frame import DataFrame
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\frame.py", line 74, in <module>
from pandas.core.series import Series
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\series.py", line 3978, in <module>
Series._add_series_or_dataframe_operations()
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\generic.py", line 8891, in _add_series_or_dataframe_operations
from pandas.core import window as rwindow
File "C:\Users\sneha\AppData\Local\Temp\InputFile.py\venv\lib\site-packages\pandas\core\window.py", line 36, in <module>
import pandas._libs.window as _window
ImportError: DLL load failed: The specified module could not be found.
I have seached for this and tried different solutions, but could not solve this errors.
Tried Solutions :
The specified module could not be found. DLL load failed
the-specified-module-could-not-be-found-dll-load-failed
the-specified-module-could-not-be-found-dll-load-failed
Try reinstalling pandas by typing this in the command-prompt
pip uninstall pandas
pip install pandas
I had similar problem when I installed pandas 0.23.0
If you are using pandas 0.23.0, uninstall it and re-install 0.22.0
It worked for my case

ImportError: cannot import name '__check_build'

I can't seem to get from sklearn.cluster import KMean to work in Python I did the whole pip install scipy/numpy and they are installed in python but I can't get the KMeans into it at the moment I have found a load of ones that are similar to my problem but I can't seem to get it working with mine.
When I do from sklearn.cluster import KMeans I just get an error that says
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
import sklearn
File "C:\Python34\lib\site-packages\sklearn\__init__.py", line 56, in <module>
from . import __check_build
ImportError: cannot import name '__check_build'
Can someone please help me I would be forever grateful!!!
This usually happens if you don't have scipy installed, so run this in your command prompt:
pip install scipy
Try this:
sudo pip install scipy
Then in Python:
import scipy

ImportError: No module named 'numpy.ma'

The full error:
import matplotlib
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import matplotlib
File "R:\Python34\lib\site-packages\matplotlib\__init__.py", line 180, in <module>
from matplotlib.cbook import is_string_like
File "R:\Python34\lib\site-packages\matplotlib\cbook.py", line 34, in <module>
import numpy.ma as ma
ImportError: No module named 'numpy.ma'
numpy is imported normally.
How do I install numpy.ma?
I also faced the same situation today. I found that I had saved a file as numpy.py, so check the filenames in your folder.
Re-install the correct version of numpy.
download correct .whl file from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
pip install C:\Path\To\Wheel\Filename.whl # for example: numpy-1.9.2+mkl-cp34-none-win_amd64.whl
Use Your (via terminal) package manager and search.
Example on Ubuntu:
aptitude search numpy
and install package.
In my case:
apt-get install python-numpy

Error importing scipy.linalg on windows (python 3.3)

I am using python 3.3 on Windows. I downloaded scipy-0.13.2.win32-py3.3.exe from scipy-lib and installed it. However, when I tried to load scipy.linalg, interpreter displayed the following errors:
>>> import scipy.linalg
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import scipy.linalg
File "C:\Python33\lib\site-packages\scipy\linalg\__init__.py", line 157, in <module>
from .misc import *
File "C:\Python33\lib\site-packages\scipy\linalg\misc.py", line 5, in <module>
from . import blas
File "C:\Python33\lib\site-packages\scipy\linalg\blas.py", line 131, in <module>
from scipy.linalg import _fblas
ImportError: DLL load failed: The specified module could not be found.
How can I resolve this issue? Between, I checked installed library modules on my PC with the github modules at linealg-scipy and they are latest, so no issue there, I guess.
To fix this issue in both Python 2.7/3, you can install scipy from here
It will work better than the version from this deposit.

Categories