我想在ubuntu12.04上安装scikit,然后按照the official installing documentation上的说明操作并在bash中输入以下命令: sudo apt-get install python-sklearn
接下来我输入测试指令 nosetests sklearn --exe
但是我遇到了很多导入错误!我搜索谷歌但发现一些有用的链接。我是python的新手,我想通过scikit学习python和机器学习。所以请帮帮我,谢谢。
下面是我在bash.Due中运行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)
答案 0 :(得分: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
应该为您提供帮助,因为您的图书馆已经存在...