我想在ubuntu12.04上安装scikit,我按照官方安装文档的说明,在bash中输入以下命令:安装python-sklearn
接下来我输入测试指令Nosetests sklearn——exe
但是我有很多导入错误!我在谷歌上搜索了一下,但没有找到什么有用的链接。我是python的新手,我想通过scikit学习python和机器学习。所以请帮帮我,谢谢。
下面是我在bash中运行nosetests命令时的错误信息。由于篇幅限制,我删除了一些错误。
EEEEEE..............EE.....EE........EE.............EEE......EE..........
======================================================================
ERROR: Failure: ImportError (No module named joblib)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/cluster/__init__.py", line 10, in <module>
from .hierarchical import ward_tree, Ward, WardAgglomeration
File "/usr/lib/pymodules/python2.7/sklearn/cluster/hierarchical.py", line 20, in <module>
from ..externals.joblib import Memory
File "/usr/lib/pymodules/python2.7/sklearn/externals/joblib/__init__.py", line 3, in <module>
from joblib import *
ImportError: No module named joblib
======================================================================
ERROR: Failure: ImportError (No module named joblib)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/covariance/__init__.py", line 14, in <module>
from .graph_lasso_ import graph_lasso, GraphLasso, GraphLassoCV
File "/usr/lib/pymodules/python2.7/sklearn/covariance/graph_lasso_.py", line 20, in <module>
from ..linear_model import lars_path
File "/usr/lib/pymodules/python2.7/sklearn/linear_model/__init__.py", line 16, in <module>
from .least_angle import Lars, LassoLars, lars_path, LARS, LassoLARS,
File "/usr/lib/pymodules/python2.7/sklearn/linear_model/least_angle.py", line 19, in <module>
from ..cross_validation import check_cv
File "/usr/lib/pymodules/python2.7/sklearn/cross_validation.py", line 21, in <module>
from .externals.joblib import Parallel, delayed
File "/usr/lib/pymodules/python2.7/sklearn/externals/joblib/__init__.py", line 3, in <module>
from joblib import *
ImportError: No module named joblib
======================================================================
ERROR: Failure: ImportError (No module named joblib)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/datasets/__init__.py", line 18, in <module>
from .lfw import load_lfw_pairs
File "/usr/lib/pymodules/python2.7/sklearn/datasets/lfw.py", line 34, in <module>
from ..externals.joblib import Memory
File "/usr/lib/pymodules/python2.7/sklearn/externals/joblib/__init__.py", line 3, in <module>
from joblib import *
ImportError: No module named joblib
======================================================================
ERROR: Failure: ImportError (No module named joblib)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/externals/joblib/__init__.py", line 3, in <module>
from joblib import *
ImportError: No module named joblib
======================================================================
ERROR: Failure: ImportError (cannot import name Parallel)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/feature_extraction/tests/test_text.py", line 10, in <module>
from sklearn.grid_search import GridSearchCV
File "/usr/lib/pymodules/python2.7/sklearn/grid_search.py", line 18, in <module>
from .cross_validation import check_cv
File "/usr/lib/pymodules/python2.7/sklearn/cross_validation.py", line 21, in <module>
from .externals.joblib import Parallel, delayed
ImportError: cannot import name Parallel
======================================================================
ERROR: Failure: ImportError (cannot import name Parallel)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/feature_selection/__init__.py", line 17, in <module>
from .rfe import RFE
File "/usr/lib/pymodules/python2.7/sklearn/feature_selection/rfe.py", line 13, in <module>
from ..cross_validation import check_cv
File "/usr/lib/pymodules/python2.7/sklearn/cross_validation.py", line 21, in <module>
from .externals.joblib import Parallel, delayed
ImportError: cannot import name Parallel
======================================================================
ERROR: Failure: ImportError (cannot import name Parallel)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/linear_model/__init__.py", line 16, in <module>
from .least_angle import Lars, LassoLars, lars_path, LARS, LassoLARS,
File "/usr/lib/pymodules/python2.7/sklearn/linear_model/least_angle.py", line 19, in <module>
from ..cross_validation import check_cv
File "/usr/lib/pymodules/python2.7/sklearn/cross_validation.py", line 21, in <module>
from .externals.joblib import Parallel, delayed
ImportError: cannot import name Parallel
======================================================================
ERROR: Failure: ImportError (cannot import name Memory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/metrics/cluster/tests/test_unsupervised.py", line 3, in <module>
from .... import datasets
File "/usr/lib/pymodules/python2.7/sklearn/datasets/__init__.py", line 18, in <module>
from .lfw import load_lfw_pairs
File "/usr/lib/pymodules/python2.7/sklearn/datasets/lfw.py", line 34, in <module>
from ..externals.joblib import Memory
ImportError: cannot import name Memory
======================================================================
ERROR: Failure: ImportError (cannot import name Memory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/metrics/tests/test_metrics.py", line 10, in <module>
from ... import datasets
File "/usr/lib/pymodules/python2.7/sklearn/datasets/__init__.py", line 18, in <module>
from .lfw import load_lfw_pairs
File "/usr/lib/pymodules/python2.7/sklearn/datasets/lfw.py", line 34, in <module>
from ..externals.joblib import Memory
ImportError: cannot import name Memory
======================================================================
ERROR: Failure: ImportError (cannot import name Memory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/utils/tests/test_sparsefuncs.py", line 5, in <module>
from sklearn.datasets import make_classification
File "/usr/lib/pymodules/python2.7/sklearn/datasets/__init__.py", line 18, in <module>
from .lfw import load_lfw_pairs
File "/usr/lib/pymodules/python2.7/sklearn/datasets/lfw.py", line 34, in <module>
from ..externals.joblib import Memory
ImportError: cannot import name Memory
======================================================================
ERROR: Failure: ImportError (cannot import name Memory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/utils/tests/test_svd.py", line 12, in <module>
from sklearn.datasets.samples_generator import make_low_rank_matrix
File "/usr/lib/pymodules/python2.7/sklearn/datasets/__init__.py", line 18, in <module>
from .lfw import load_lfw_pairs
File "/usr/lib/pymodules/python2.7/sklearn/datasets/lfw.py", line 34, in <module>
from ..externals.joblib import Memory
ImportError: cannot import name Memory
======================================================================
ERROR: Tests that clone creates a correct deep copy.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/usr/lib/pymodules/python2.7/sklearn/tests/test_base.py", line 48, in test_clone
from sklearn.feature_selection import SelectFpr, f_classif
File "/usr/lib/pymodules/python2.7/sklearn/feature_selection/__init__.py", line 17, in <module>
from .rfe import RFE
File "/usr/lib/pymodules/python2.7/sklearn/feature_selection/rfe.py", line 13, in <module>
from ..cross_validation import check_cv
File "/usr/lib/pymodules/python2.7/sklearn/cross_validation.py", line 21, in <module>
from .externals.joblib import Parallel, delayed
ImportError: cannot import name Parallel
======================================================================
ERROR: Tests that clone doesn't copy everything.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/usr/lib/pymodules/python2.7/sklearn/tests/test_base.py", line 64, in test_clone_2
from sklearn.feature_selection import SelectFpr, f_classif
File "/usr/lib/pymodules/python2.7/sklearn/feature_selection/__init__.py", line 17, in <module>
from .rfe import RFE
File "/usr/lib/pymodules/python2.7/sklearn/feature_selection/rfe.py", line 13, in <module>
from ..cross_validation import check_cv
File "/usr/lib/pymodules/python2.7/sklearn/cross_validation.py", line 21, in <module>
from .externals.joblib import Parallel, delayed
ImportError: cannot import name Parallel
======================================================================
ERROR: sklearn.tests.test_base.test_is_classifier
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/usr/lib/pymodules/python2.7/sklearn/tests/test_base.py", line 109, in test_is_classifier
from ..svm import SVC
File "/usr/lib/pymodules/python2.7/sklearn/svm/__init__.py", line 13, in <module>
from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC
File "/usr/lib/pymodules/python2.7/sklearn/svm/classes.py", line 2, in <module>
from ..linear_model.base import CoefSelectTransformerMixin
File "/usr/lib/pymodules/python2.7/sklearn/linear_model/__init__.py", line 16, in <module>
from .least_angle import Lars, LassoLars, lars_path, LARS, LassoLARS,
File "/usr/lib/pymodules/python2.7/sklearn/linear_model/least_angle.py", line 19, in <module>
from ..cross_validation import check_cv
File "/usr/lib/pymodules/python2.7/sklearn/cross_validation.py", line 21, in <module>
from .externals.joblib import Parallel, delayed
ImportError: cannot import name Parallel
======================================================================
ERROR: Failure: ImportError (cannot import name Memory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/tests/test_cross_validation.py", line 10, in <module>
from ..datasets import make_regression
File "/usr/lib/pymodules/python2.7/sklearn/datasets/__init__.py", line 18, in <module>
from .lfw import load_lfw_pairs
File "/usr/lib/pymodules/python2.7/sklearn/datasets/lfw.py", line 34, in <module>
from ..externals.joblib import Memory
ImportError: cannot import name Memory
======================================================================
ERROR: Failure: ImportError (cannot import name Parallel)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/tests/test_grid_search.py", line 12, in <module>
from sklearn.grid_search import GridSearchCV
File "/usr/lib/pymodules/python2.7/sklearn/grid_search.py", line 18, in <module>
from .cross_validation import check_cv
File "/usr/lib/pymodules/python2.7/sklearn/cross_validation.py", line 21, in <module>
from .externals.joblib import Parallel, delayed
ImportError: cannot import name Parallel
======================================================================
ERROR: Failure: ImportError (cannot import name Memory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/tests/test_hmm.py", line 6, in <module>
from sklearn.datasets.samples_generator import make_spd_matrix
File "/usr/lib/pymodules/python2.7/sklearn/datasets/__init__.py", line 18, in <module>
from .lfw import load_lfw_pairs
File "/usr/lib/pymodules/python2.7/sklearn/datasets/lfw.py", line 34, in <module>
from ..externals.joblib import Memory
ImportError: cannot import name Memory
======================================================================
ERROR: Failure: ImportError (cannot import name Parallel)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/tests/test_multiclass.py", line 13, in <module>
from sklearn.svm import LinearSVC
File "/usr/lib/pymodules/python2.7/sklearn/svm/__init__.py", line 13, in <module>
from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC
File "/usr/lib/pymodules/python2.7/sklearn/svm/classes.py", line 2, in <module>
from ..linear_model.base import CoefSelectTransformerMixin
File "/usr/lib/pymodules/python2.7/sklearn/linear_model/__init__.py", line 16, in <module>
from .least_angle import Lars, LassoLars, lars_path, LARS, LassoLARS,
File "/usr/lib/pymodules/python2.7/sklearn/linear_model/least_angle.py", line 19, in <module>
from ..cross_validation import check_cv
File "/usr/lib/pymodules/python2.7/sklearn/cross_validation.py", line 21, in <module>
from .externals.joblib import Parallel, delayed
ImportError: cannot import name Parallel
======================================================================
ERROR: Failure: ImportError (cannot import name Parallel)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/tests/test_pipeline.py", line 9, in <module>
from ..svm import SVC
File "/usr/lib/pymodules/python2.7/sklearn/svm/__init__.py", line 13, in <module>
from .classes import SVC, NuSVC, SVR, NuSVR, OneClassSVM, LinearSVC
File "/usr/lib/pymodules/python2.7/sklearn/svm/classes.py", line 2, in <module>
from ..linear_model.base import CoefSelectTransformerMixin
File "/usr/lib/pymodules/python2.7/sklearn/linear_model/__init__.py", line 16, in <module>
from .least_angle import Lars, LassoLars, lars_path, LARS, LassoLARS,
File "/usr/lib/pymodules/python2.7/sklearn/linear_model/least_angle.py", line 19, in <module>
from ..cross_validation import check_cv
File "/usr/lib/pymodules/python2.7/sklearn/cross_validation.py", line 21, in <module>
from .externals.joblib import Parallel, delayed
ImportError: cannot import name Parallel
======================================================================
ERROR: Failure: ImportError (cannot import name Memory)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/usr/lib/pymodules/python2.7/sklearn/tests/test_pls.py", line 3, in <module>
from sklearn.datasets import load_linnerud
File "/usr/lib/pymodules/python2.7/sklearn/datasets/__init__.py", line 18, in <module>
from .lfw import load_lfw_pairs
File "/usr/lib/pymodules/python2.7/sklearn/datasets/lfw.py", line 34, in <module>
from ..externals.joblib import Memory
ImportError: cannot import name Memory
======================================================================
FAIL: Test either above import has failed for some reason
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
self.test(*self.arg)
File "/usr/lib/pymodules/python2.7/sklearn/tests/test_init.py", line 22, in test_import_skl
assert_equal(_top_import_error, None)
AssertionError: ImportError('cannot import name Parallel',) != None
----------------------------------------------------------------------
Ran 100 tests in 6.478s
FAILED (errors=26, failures=1)
检查python-joblib
包是否安装
sudo dpkg -l | grep joblib
如果没有返回,尝试运行
apt-cache search joblib
应该有一个名为python-joblib
的包:使用
sudo apt-get install python-joblib
并重试。
编辑:
你是对的,那个包被安装了,但是Python似乎无法找到它(由你的import joblib
失败证明)。通常这意味着包的安装路径不是Python搜索路径的一部分。
您可以做的是从源代码手动安装模块并指定路径(似乎是/usr/lib/python2.7
),或者使用easy_install
或pip
等工具为您完成此操作。
正如指南中所述,pip install -U scikit-learn
或easy_install -U scikit-learn
应该可以满足您的要求,因为您的库已经在那里了…