Search code examples
pythonpython-3.xscikit-learnpippackage-managers

Facing error messages when importing sklearn in python i.d


I get an error when importing sklearn in python 3.9. I am using I.D.L.E. in Windows. Installed it using cmd command: pip install -U scikit-learn as given in https://scikit-learn.org/stable/install.html

The received error message is:

Traceback (most recent call last):
  File "<pyshell#9>", line 1, in <module>
    import sklearn
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\__init__.py", line 82, in <module>
    from .base import clone
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\base.py", line 17, in <module>
    from .utils import _IS_32BIT
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\__init__.py", line 29, in <module>
    from .fixes import parse_version, threadpool_info
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\fixes.py", line 19, in <module>
    import scipy.stats
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\stats\__init__.py", line 453, in <module>
    from ._stats_py import *
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\stats\_stats_py.py", line 38, in <module>
    from scipy.spatial.distance import cdist
  File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\spatial\__init__.py", line 104, in <module>
    from ._qhull import *
ImportError: DLL load failed while importing _qhull: The specified module could not be found.

Please help.


Solution

  • Apparently my scipy got corrupted somehow. Uninstalling and re-installing it fixed the problem. Thanks everyone who took their time and effort to help though.