【发布时间】:2020-07-21 05:00:04
【问题描述】:
我在尝试从 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)
【问题讨论】:
-
无论如何,
from numpy import mean是个糟糕的主意。请改用import numpy as np和np.mean()。
标签: python scikit-learn scipy