Sklearn导入错误.在ubuntu 14.04上没有名为winregg的模块



当我尝试从sklearn导入一个模块时,收到一个错误:

In [1]: import sklearn
In [2]: from sklearn.linear_model import Lasso
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-b932cb9c16f8> in <module>()
----> 1 from sklearn.linear_model import Lasso
/usr/local/lib/python3.4/dist-packages/sklearn/linear_model/__init__.py in <module>()
     10 # complete documentation.
     11 
---> 12 from .base import LinearRegression
     13 
     14 from .bayes import BayesianRidge, ARDRegression
/usr/local/lib/python3.4/dist-packages/sklearn/linear_model/base.py in <module>()
     26 from ..externals.joblib import Parallel, delayed
     27 from ..base import BaseEstimator, ClassifierMixin, RegressorMixin
---> 28 from ..utils import as_float_array, atleast2d_or_csr, safe_asarray
     29 from ..utils.extmath import safe_sparse_dot
     30 from ..utils.sparsefuncs import mean_variance_axis0, inplace_column_scale
/usr/local/lib/python3.4/dist-packages/sklearn/utils/__init__.py in <module>()
      9 
     10 from .murmurhash import murmurhash3_32
---> 11 from .validation import (as_float_array, check_arrays, safe_asarray,
     12                          assert_all_finite, array2d, atleast2d_or_csc,
     13                          atleast2d_or_csr, warn_if_not_float,
/usr/local/lib/python3.4/dist-packages/sklearn/utils/validation.py in <module>()
     15 
     16 from ..externals import six
---> 17 from .fixes import safe_copy
     18 
     19 
/usr/local/lib/python3.4/dist-packages/sklearn/utils/fixes.py in <module>()
    103 
    104 try:
--> 105     with ignore_warnings():
    106         # Don't raise the numpy deprecation warnings that appear in
    107         # 1.9
/usr/local/lib/python3.4/dist-packages/sklearn/utils/testing.py in __enter__(self)
    297 
    298     def __enter__(self):
--> 299         clean_warning_registry()  # be safe and not propagate state + chaos
    300         warnings.simplefilter('always')
    301         if self._entered:
/usr/local/lib/python3.4/dist-packages/sklearn/utils/testing.py in clean_warning_registry()
    582     reg = "__warningregistry__"
    583     for mod in sys.modules.copy().values():
--> 584         if hasattr(mod, reg):
    585             getattr(mod, reg).clear()
    586 
/usr/lib/python3/dist-packages/scipy/lib/six.py in __getattr__(self, attr)
    114         if attr in ("__file__", "__name__") and self.mod not in sys.modules:
    115             raise AttributeError
--> 116         _module = self._resolve()
    117         value = getattr(_module, attr)
    118         setattr(self, attr, value)
/usr/lib/python3/dist-packages/scipy/lib/six.py in _resolve(self)
    103 
    104     def _resolve(self):
--> 105         return _import_module(self.mod)
    106 
    107     def __getattr__(self, attr):
/usr/lib/python3/dist-packages/scipy/lib/six.py in _import_module(name)
     74 def _import_module(name):
     75     """Import module, returning the module after the last dot."""
---> 76     __import__(name)
     77     return sys.modules[name]
     78 
ImportError: No module named 'winreg'
In [3]: 

我已经使用官方文档

中解释的命令pip3安装了sklearn。
In [3]: sklearn.__version__
Out[3]: '0.15.1'

winreg应该是一个只适用于windows的模块…我怎么解决这个问题?

编辑:这是我用来安装sklearn的命令:

sudo pip3 install -U scikit-learn

我已经解决了删除sklearn并安装git版本的问题https://askubuntu.com/questions/449326/installation-error-in-sklearn-for-python3

相关内容

  • 没有找到相关文章

最新更新