Python ModuleNotFoundError:没有名为“numpy.testing.nosetester”的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/59474533/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ModuleNotFoundError: No module named 'numpy.testing.nosetester'
提问by jiuseki
I was using the Decision Tree and this error was raised. The same situation appeared when I used Back Propagation. How can I solve it? (Sorry for my poor English)
我正在使用决策树并引发了此错误。当我使用反向传播时,出现了同样的情况。我该如何解决?(抱歉我的英语不好)
import pandas as pd
import numpy as np
a = np.test()
f = open('E:/lgdata.csv')
data = pd.read_csv(f,index_col = 'id')
x = data.iloc[:,10:12].as_matrix().astype(int)
y = data.iloc[:,9].as_matrix().astype(int)
from sklearn.tree import DecisionTreeClassifier as DTC
dtc = DTC(criterion='entropy')
dtc.fit(x,y)
x=pd.DataFrame(x)
from sklearn.tree import export_graphviz
with open('tree.dot','w') as f1:
f1 = export_graphviz(dtc, feature_names = x.columns, out_file = f1)
Traceback (most recent call last):
??File "<ipython-input-40-4359c06ae1f0>", line 1, in <module>
????runfile('C:/ProgramData/Anaconda3/lib/site-packages/scipy/_lib/_numpy_compat.py', wdir='C:/ProgramData/Anaconda3/lib/site-packages/scipy/_lib')
??File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile
????execfile(filename, namespace)
??File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile
????exec(compile(f.read(), filename, 'exec'), namespace)
??File "C:/ProgramData/Anaconda3/lib/site-packages/scipy/_lib/_numpy_compat.py", line 9, in <module>
????from numpy.testing.nosetester import import_noseModuleNotFoundError: No module named 'numpy.testing.nosetester'
回溯(最近一次调用):
??File "<ipython-input-40-4359c06ae1f0>", line 1, in <module>
????runfile('C:/ProgramData/Anaconda3/lib/site-packages/ scipy/_lib/_numpy_compat.py', wdir='C:/ProgramData/Anaconda3/lib/site-packages/scipy/_lib')
??File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils \site\sitecustomize.py", line 710, in runfile
????execfile(filename, namespace)
??File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py" ,第 101 行,在 execfile
????exec(compile(f.read(), filename, 'exec'), namespace)
??File "C:/ProgramData/Anaconda3/lib/site-packages/scipy/_lib/ _numpy_compat.py”,第 9 行,在 <module> 中
????来自 numpy.testing.nosetester 导入 import_noseModuleNotFoundError:没有名为“numpy.testing.nosetester”的模块
回答by thushv89
This is happening due to a version incompatibility between numpy
and scipy
. numpy
in its latest versions have deprecated numpy.testing.nosetester
.
这是由于numpy
和之间的版本不兼容而发生的scipy
。numpy
在其最新版本中已弃用numpy.testing.nosetester
。
Replicating the issue
复制问题
pip install numpy==1.18 # > 1.18
pip install scipy<=0.19.0 # <= 0.19
and
和
from sklearn.tree import DecisionTreeClassifier as DTC
Triggers the error.
触发错误。
Fixing the error
修复错误
Upgrade your scipy
to a higher version.
将您升级scipy
到更高版本。
pip install numpy==1.18
pip install scipy==1.1.0
pip install scikit-learn==0.21.3
But not limited to this. By upgrading the above libraries to the latest stable, you should be able to get rid of this error.
但不限于此。通过将上述库升级到最新的稳定版,您应该能够摆脱这个错误。
回答by Prince Mathur
I was facing the same error while using lexnlp package Got it fixed by installing:
我在使用 lexnlp 包时遇到了同样的错误 通过安装修复了它:
scipy==1.4.1
pandas==0.23.4
numpy==1.18.1
lexnlp==0.2.7.1
(Only install lexnlp if know you're explicitly using it in your project and you know what you're doing)
(只有在知道您在项目中明确使用它并且知道自己在做什么的情况下才安装 lexnlp)
回答by Md.Habibur Rahman
try installing numpy version 1.17.0 using pip or pip3 (assuming you already installed pip3)
尝试使用 pip 或 pip3 安装 numpy 版本 1.17.0(假设您已经安装了 pip3)
pip3 install numpy==1.17.0
回答by Lawrence Patrick
I solved this by:
我通过以下方式解决了这个问题:
pip uninstall numpy pip install numpy == 1.17.0
pip卸载numpy pip安装numpy == 1.17.0
and using:
并使用:
from numpy.testing import rundocs