Python 导入错误:没有名为nose.tools 的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25398915/
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
ImportError: No module named nose.tools
提问by PANG SEOK MUN S4-02
I encounter some difficulties loading dataset onto my programme. I am unsure of the import error as stated below.
我在将数据集加载到我的程序中时遇到了一些困难。我不确定如下所述的导入错误。
Traceback (most recent call last):
File "C:\Users\Khoo Family\Downloads\lsa_clustering (3).py", line 4, in <module>
from sklearn.datasets import fetch_20newsgroups
File "C:\Python27\lib\site-packages\sklearn\datasets\__init__.py", line 7, in <module>
from .base import load_diabetes
File "C:\Python27\lib\site-packages\sklearn\datasets\base.py", line 25, in <module>
from ..utils import check_random_state
File "C:\Python27\lib\site-packages\sklearn\utils\__init__.py", line 11, in <module>
from .validation import (as_float_array, check_arrays, safe_asarray,
File "C:\Python27\lib\site-packages\sklearn\utils\validation.py", line 17, in <module>
from .fixes import safe_copy
File "C:\Python27\lib\site-packages\sklearn\utils\fixes.py", line 18, in <module>
from .testing import ignore_warnings
File "C:\Python27\lib\site-packages\sklearn\utils\testing.py", line 36, in <module>
from nose.tools import assert_equal
ImportError: No module named nose.tools
回答by Artem Fedosov
Check if nose in a list of installed python packages. You can do it in python console(windows + R, type cmd then enter, type python then enter):
检查已安装的python 包列表中是否有nose。您可以在python 控制台中执行此操作(windows + R,键入 cmd 然后回车,键入 python 然后回车):
>>> help('modules')
If nose is there, then you either have a problem with PYTHONPATH when running your code or you using another interpreter to run console and your code.
如果鼻子在那里,那么您要么在运行代码时遇到 PYTHONPATH 问题,要么使用另一个解释器来运行控制台和代码。
If nose not in a list, do in your console(windows + R, type cmd, then enter):
如果鼻子不在列表中,请在控制台中执行(Windows + R,键入 cmd,然后输入):
pip install nose
回答by Carlo Allocca
You have probably named your file starting with "test_", change it and it should solve the problem. Thanks.
您可能已将文件命名为以“test_”开头,更改它应该可以解决问题。谢谢。
回答by MD SHADIQUE
You probably have a file name- "nose.py" in your program folder because of that it is talking that nose.py as a module not the installed original nose module.
您的程序文件夹中可能有一个文件名-“nose.py”,因为它将nose.py 视为一个模块而不是已安装的原始nose 模块。
If not them please try installing it first by using the following command.
如果不是,请先尝试使用以下命令安装它。
pip install nose

