westlose
westlose

Reputation: 21

Python : Failing to install scikit-learn (error code 1) on widows

I followed the instructions on the official sklearn website, and even if I fulfil the requirements I still cannot install sklearn. Here is the error message I get :

ERROR: Command errored out with exit status 1:
     command: 'd:\others\python\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\anath\\AppData\\Local\\Temp\\pip-install-dnha64ok\\scikit-learn\\setup.py'"'"'; __file__='"'"'C:\\Users\\anath\\AppData\\Local\\Temp\\pip-install-dnha64ok\\scikit-learn\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\anath\AppData\Local\Temp\pip-record-s7idmuvg\install-record.txt' --single-version-externally-managed --compile
         cwd: C:\Users\anath\AppData\Local\Temp\pip-install-dnha64ok\scikit-learn\
    Complete output (44 lines):
    Partial import of sklearn during the build process.
    No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils 
    Traceback (most recent call last):
      File "d:\others\python\lib\site-packages\setuptools\msvc.py", line 489, in _find_latest_available_vc_ver
        return self.find_available_vc_vers()[-1]
    IndexError: list index out of range

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\anath\AppData\Local\Temp\pip-install-dnha64ok\scikit-learn\setup.py", line 290, in <module>
        setup_package()
      File "C:\Users\anath\AppData\Local\Temp\pip-install-dnha64ok\scikit-learn\setup.py", line 286, in setup_package
        setup(**metadata)
      File "d:\others\python\lib\site-packages\numpy\distutils\core.py", line 137, in setup   
        config = configuration()
      File "C:\Users\anath\AppData\Local\Temp\pip-install-dnha64ok\scikit-learn\setup.py", line 174, in configuration
        config.add_subpackage('sklearn')
      File "d:\others\python\lib\site-packages\numpy\distutils\misc_util.py", line 1033, in add_subpackage
        config_list = self.get_subpackage(subpackage_name, subpackage_path,
      File "d:\others\python\lib\site-packages\numpy\distutils\misc_util.py", line 999, in get_subpackage
        config = self._get_configuration_from_setup_py(
      File "d:\others\python\lib\site-packages\numpy\distutils\misc_util.py", line 941, in _get_configuration_from_setup_py
        config = setup_module.configuration(*args)
      File "sklearn\setup.py", line 76, in configuration
        maybe_cythonize_extensions(top_path, config)
      File "C:\Users\anath\AppData\Local\Temp\pip-install-dnha64ok\scikit-learn\sklearn\_build_utils\__init__.py", line 42, in maybe_cythonize_extensions
        with_openmp = check_openmp_support()
      File "C:\Users\anath\AppData\Local\Temp\pip-install-dnha64ok\scikit-learn\sklearn\_build_utils\openmp_helpers.py", line 83, in check_openmp_support
        ccompiler.compile(['test_openmp.c'], output_dir='objects',
      File "d:\others\python\lib\distutils\_msvccompiler.py", line 360, in compile
        self.initialize()
      File "d:\others\python\lib\distutils\_msvccompiler.py", line 253, in initialize
        vc_env = _get_vc_env(plat_spec)
      File "d:\others\python\lib\site-packages\setuptools\msvc.py", line 185, in msvc14_get_vc_env
        return EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env()
      File "d:\others\python\lib\site-packages\setuptools\msvc.py", line 843, in __init__     
        self.si = SystemInfo(self.ri, vc_ver)
      File "d:\others\python\lib\site-packages\setuptools\msvc.py", line 485, in __init__     
        self.vc_ver = vc_ver or self._find_latest_available_vc_ver()
available_vc_ver
    distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\anath\\AppData\\Local\\Temp\\pip-installpip-install-dnha64ok\\scikit-learn\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\anath\AppData\Local\Temp\pip-record-s7idmuvg\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.

It seems like there is a problem with numpy but I already updated to the latest version. I'm on Windows 10, using Python 3.7, and numpy/scipy are up to date. Thanks in advance !

Upvotes: 2

Views: 5372

Answers (3)

Đ.J vicky
Đ.J vicky

Reputation: 61

Upgrade your python to 3.8 ,because 3.9.0 also have this installation issue.

Upvotes: 1

Epsi95
Epsi95

Reputation: 9047

You can go to this site for Binaries for windows:

https://www.lfd.uci.edu/~gohlke/pythonlibs/

here you can find required packages if you don't want to install C++ build tools

Upvotes: 0

techdoodle
techdoodle

Reputation: 115

I think your problem is with setuptools. Upgrade it using the following command:

pip3 install --upgrade setuptools

And then upgrade your scipy/numpy to the latest version :

pip3 install --upgrade numpy

Your C++ build tools are missing too. Get it from here: https://visualstudio.microsoft.com/visual-cpp-build-tools/

Upvotes: 0

Related Questions