1

I'm getting the following error while trying to import from sklearn

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

Here is the 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)
Randy
  • 14,349
  • 2
  • 36
  • 42
  • Does this answer your question? [ImportError in importing from sklearn: cannot import name check\_build](https://stackoverflow.com/questions/15274696/importerror-in-importing-from-sklearn-cannot-import-name-check-build) –  Apr 08 '20 at 17:33
  • In any case, `from numpy import mean` is a terrible idea. Use `import numpy as np` and `np.mean()` instead. – desertnaut Apr 08 '20 at 17:51

1 Answers1

1

I was having the same problem, but i managed to solve it..Worth your time to try: Please follow the sequence. in CMD,

    • a) pip uninstall numpy

    • b) pip uninstall scipy

    • c) pip uninstall matplotlib

    • d) pip uninstall sklearn

    • e) pip uninstall scikit-learn

Then,

    • a) pip install numpy
    • b) pip install scipy
    • c) pip install matplotlib
    • d) pip install sklearn
    • e) pip install scikit-learn

Follow 1a) to 1e) , then 2a) to 2e).

Ruli
  • 2,592
  • 12
  • 30
  • 40
Tzhoji
  • 11
  • 2