gpt4 book ai didi

python - 无法从 'parse_version' 导入名称 'sklearn.utils.fixes'

转载 作者:行者123 更新时间:2023-12-04 12:57:39 62 4
gpt4 key购买 nike

我在使用 sklearn 时遇到了严重的问题。特别是,在执行以下操作时:

from sklearn.linear_model import LinearRegression
我收到以下错误:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-8-a35af2a4e137> in <module>
----> 1 from sklearn.linear_model import LinearRegression

~/anaconda3/lib/python3.7/site-packages/sklearn/__init__.py in <module>
78 from . import _distributor_init # noqa: F401
79 from . import __check_build # noqa: F401
---> 80 from .base import clone
81 from .utils._show_versions import show_versions
82

~/anaconda3/lib/python3.7/site-packages/sklearn/base.py in <module>
19 from . import __version__
20 from ._config import get_config
---> 21 from .utils import _IS_32BIT
22 from .utils.validation import check_X_y
23 from .utils.validation import check_array

~/anaconda3/lib/python3.7/site-packages/sklearn/utils/__init__.py in <module>
21
22 from .murmurhash import murmurhash3_32
---> 23 from .class_weight import compute_class_weight, compute_sample_weight
24 from . import _joblib
25 from ..exceptions import DataConversionWarning

~/anaconda3/lib/python3.7/site-packages/sklearn/utils/class_weight.py in <module>
5 import numpy as np
6
----> 7 from .validation import _deprecate_positional_args
8
9

~/anaconda3/lib/python3.7/site-packages/sklearn/utils/validation.py in <module>
23 from contextlib import suppress
24
---> 25 from .fixes import _object_dtype_isnan, parse_version
26 from .. import get_config as _get_config
27 from ..exceptions import NonBLASDotWarning, PositiveSpectrumWarning

ImportError: cannot import name 'parse_version' from 'sklearn.utils.fixes' (/Users/federiconutarelli/anaconda3/lib/python3.7/site-packages/sklearn/utils/fixes.py)
我无法修复,因为在 fix.py 中我可以看到
def _parse_version(version_string):
version = []
for x in version_string.split('.'):
try:
version.append(int(x))
except ValueError:
# x may be of the form dev-1ea1592
version.append(x)
return tuple(version)
在我看来,这与 parse_version 相同。为什么会发生此错误?谁能帮帮我吗?
谢谢你们,
费德里科

最佳答案

您可以通过创建新的 conda 环境来解决此问题。有时,某些冲突会阻止软件包正确运行。

关于python - 无法从 'parse_version' 导入名称 'sklearn.utils.fixes',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64433329/

62 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com