ImportError:无法从部分初始化模块'sklearn'导入名称check_build

时间:2020-04-08 17:28:47

标签: python scikit-learn scipy

尝试从sklearn导入时出现以下错误

from pandas import read_csv
from numpy import mean
from matplotlib import pyplot
from sklearn.metrics import mean_squared_error

这是错误:

ImportError                               Traceback (most recent call last)
<ipython-input-1-c57768f466c0> in <module>
      2 from numpy import mean
      3 from matplotlib import pyplot
----> 4 from sklearn.metrics import mean_squared_error

~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sklearn\__init__.py in <module>
     79     # it and importing it first would fail if the OpenMP dll cannot be found.
     80     from . import _distributor_init  # noqa: F401
---> 81     from . import __check_build  # noqa: F401
     82     from .base import clone
     83     from .utils._show_versions import show_versions

ImportError: cannot import name '__check_build' from partially initialized module 'sklearn' (most likely due to a circular import) (C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sklearn\__init__.py)

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,但是我设法解决了。.值得您花时间尝试: 请按照顺序进行。 在CMD中,

    • a)pip卸载numpy

    • b)pip卸载scipy

    • c)pip卸载matplotlib

    • d)pip卸载sklearn

    • e)pip卸载scikit-learn

然后

    • a)点安装numpy
    • b)点安装scipy
    • c)pip安装matplotlib
    • d)点安装sklearn
    • e)点安装scikit-learn

按照1a)至1e),然后按照2a)至2e)。