机器学习和Python的新手。 sklearn下的任何模型都无法导入。几天前它在工作。但是后来我更新了anaconda,因为那时遇到了OS错误问题。我要去哪里错了?
预先感谢
我正在使用Jupyter Notebook python3.6,Win 10。 我尝试过
import sklearn
assert sklearn.__version__ >= "0.20"
我升级了所有超出文档中提到的库: sklearn 0.21.3
numpy 1.16.5
scipy 1.3.1
joblib 0.13.2
我重新安装了Python的Anaconda,删除了“用户”文件夹下的根目录
也阅读 Cannot import sklearn.model_selection in scikit-learn
from sklearn.model_selection import train_test_split
OSError Traceback (most recent call last)
<ipython-input-3-73edc048c06b> in <module>
----> 1 from sklearn.model_selection import train_test_split
~\Anaconda3\lib\site-packages\sklearn\model_selection\__init__.py in
<module>
17 from ._split import check_cv
18
---> 19 from ._validation import cross_val_score
20 from ._validation import cross_val_predict
21 from ._validation import cross_validate
~\Anaconda3\lib\site-packages\sklearn\model_selection\_validation.py in
<module>
25 from ..utils.metaestimators import _safe_split
26 from ..utils._joblib import Parallel, delayed
---> 27 from ..metrics.scorer import check_scoring,
_check_multimetric_scoring
28 from ..exceptions import FitFailedWarning
29 from ._split import check_cv
~\Anaconda3\lib\site-packages\sklearn\metrics\__init__.py in <module>
5
6
----> 7 from .ranking import auc
8 from .ranking import average_precision_score
9 from .ranking import coverage_error
~\Anaconda3\lib\site-packages\sklearn\metrics\ranking.py in <module>
33 from ..utils.sparsefuncs import count_nonzero
34 from ..exceptions import UndefinedMetricWarning
---> 35 from ..preprocessing import label_binarize
36
37 from .base import _average_binary_score
~\Anaconda3\lib\site-packages\sklearn\preprocessing\__init__.py in <module>
4 """
5
----> 6 from ._function_transformer import FunctionTransformer
7
8 from .data import Binarizer
~\Anaconda3\lib\site
packages\sklearn\preprocessing\_function_transformer.py in <module>
3 from ..base import BaseEstimator, TransformerMixin
4 from ..utils import check_array
----> 5 from ..utils.testing import assert_allclose_dense_sparse
6
7
~\Anaconda3\lib\site-packages\sklearn\utils\testing.py in <module>
716
717 try:
--> 718 import pytest
719
720 skip_if_32bit = pytest.mark.skipif(_IS_32BIT,
~\Anaconda3\lib\site-packages\pytest.py in <module>
4 """
5 from _pytest import __version__
----> 6 from _pytest.assertion import register_assert_rewrite
7 from _pytest.config import cmdline
8 from _pytest.config import hookimpl
~\Anaconda3\lib\site-packages\_pytest\assertion\__init__.py in <module>
5 from typing import Optional
6
7 from _pytest.assertion import rewrite
8 from _pytest.assertion import truncate
9 from _pytest.assertion import util
~\Anaconda3\lib\site-packages\_pytest\assertion\rewrite.py in <module>
24 from _pytest._io.saferepr import saferepr
25 from _pytest._version import version
---> 26 from _pytest.assertion import util
27 from _pytest.assertion.util import ( # noqa: F401
28 format_explanation as _format_explanation,
~\Anaconda3\lib\site-packages\_pytest\assertion\util.py in
<module>
6 from typing import Optional
7
----> 8 import _pytest._code
9 from _pytest import outcomes
10 from _pytest._io.saferepr import saferepr
~\Anaconda3\lib\site-packages\_pytest\_code\__init__.py in <module>
1 """ python inspection/code generation API """
----> 2 from .code import Code # noqa
3 from .code import ExceptionInfo # noqa
4 from .code import filter_traceback # noqa
5 from .code import Frame # noqa
~\Anaconda3\lib\site-packages\_pytest\_code\code.py in <module>
21
22 import attr
---> 23 import pluggy
24 import py
25
~\Anaconda3\lib\site-packages\pluggy\__init__.py in <module>
14 ]
15
---> 16 from .manager import PluginManager, PluginValidationError
17 from .callers import HookCallError
18 from .hooks import HookspecMarker, HookimplMarker
~\Anaconda3\lib\site-packages\pluggy\manager.py in <module>
9 from importlib import metadata as importlib_metadata
10 else:
---> 11 import importlib_metadata
12
13
~\Anaconda3\lib\site-packages\importlib_metadata\__init__.py in <module>
545
546
--> 547 __version__ = version(__name__)
~\Anaconda3\lib\site-packages\importlib_metadata\__init__.py in version(distribution_name)
507 "Version" metadata key.
508 """
--> 509 return distribution(distribution_name).version
510
511
~\Anaconda3\lib\site-packages\importlib_metadata\__init__.py in distribution(distribution_name)
480 :return: A ``Distribution`` instance (or subclass thereof).
481 """
--> 482 return Distribution.from_name(distribution_name)
483
484
~\Anaconda3\lib\site-packages\importlib_metadata\__init__.py in from_name(cls, name)
181 context = DistributionFinder.Context(name=name)
182 dists = cls._maybe_bind(resolver, context)
--> 183 dist = next(dists, None)
184 if dist is not None:
185 return dist
~\Anaconda3\lib\site-packages\importlib_metadata\__init__.py in <genexpr>(.0)
423 return itertools.chain.from_iterable(
424 cls._search_path(path, pattern)
--> 425 for path in map(cls._switch_path, paths)
426 )
427
~\Anaconda3\lib\site-packages\importlib_metadata\__init__.py in _search_path(cls, root, pattern)
447 @classmethod
448 def _search_path(cls, root, pattern):
--> 449 if not root.is_dir():
450 return ()
451 normalized = pattern.replace('-', '_')
~\Anaconda3\lib\pathlib.py in is_dir(self)
1356 """
1357 try:
-> 1358 return S_ISDIR(self.stat().st_mode)
1359 except OSError as e:
1360 if not _ignore_error(e):
~\Anaconda3\lib\pathlib.py in stat(self)
1166 os.stat() does.
1167 """
-> 1168 return self._accessor.stat(self)
1169
1170 def owner(self):
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect:
'C:\\Users\\Omkar\\$SPARK_HOME\\python:$SPARK_HOME\\python\\lib\\py4j-VERSION-src.zip:$PYTHONPATH' ```