Facing error messages when importing sklearn in python i.d

Question:

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:UsersUSERAppDataLocalProgramsPythonPython39libsite-packagessklearn__init__.py", line 82, in <module>
    from .base import clone
  File "C:UsersUSERAppDataLocalProgramsPythonPython39libsite-packagessklearnbase.py", line 17, in <module>
    from .utils import _IS_32BIT
  File "C:UsersUSERAppDataLocalProgramsPythonPython39libsite-packagessklearnutils__init__.py", line 29, in <module>
    from .fixes import parse_version, threadpool_info
  File "C:UsersUSERAppDataLocalProgramsPythonPython39libsite-packagessklearnutilsfixes.py", line 19, in <module>
    import scipy.stats
  File "C:UsersUSERAppDataLocalProgramsPythonPython39libsite-packagesscipystats__init__.py", line 453, in <module>
    from ._stats_py import *
  File "C:UsersUSERAppDataLocalProgramsPythonPython39libsite-packagesscipystats_stats_py.py", line 38, in <module>
    from scipy.spatial.distance import cdist
  File "C:UsersUSERAppDataLocalProgramsPythonPython39libsite-packagesscipyspatial__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.

Asked By: Surya Majumder

||

Answers:

Since the required file _qhull.yp39-win_amd64.pyd is there, it must be a problem with the dependencies this DLL file has and can’t find on your computer.

Use a dependency walker like this one to find out what is missing on your system and see that you get those missing pieces installed.

Quite likely you are missing some of the Microsoft Redistributable Visual Studio Files.

Answered By: Frank

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.

Answered By: Surya Majumder