无法安装 scikit-learn,但它无法在窗口 8.1 的 jupyter notebook 中的 python 3.10 中安装 [重复]

Posted

技术标签:

【中文标题】无法安装 scikit-learn,但它无法在窗口 8.1 的 jupyter notebook 中的 python 3.10 中安装 [重复]【英文标题】:Failed to install scikit-learn but it could not in python 3.10 in jupyter notebook in window 8.1 [duplicate] 【发布时间】:2022-01-05 01:29:00 【问题描述】:
 ERROR: Command errored out with exit status 1:
   command: 'G:\python\python.exe' 'G:\python\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\Zaid\AppData\Local\Temp\tmp9x904_3n'
       cwd: C:\Users\Zaid\AppData\Local\Temp\pip-install-hkon2hc1\scikit-learn_da5359c4d7ad4dadb4a1f14623e7a4ac
  Complete output (46 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 "G:\python\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in <module>
      main()
    File "G:\python\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 345, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "G:\python\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 164, in prepare_metadata_for_build_wheel
      return hook(metadata_directory, config_settings)
    File "C:\Users\Zaid\AppData\Local\Temp\pip-build-env-ozjc6kz_\overlay\Lib\site-packages\setuptools\build_meta.py", line 174, in prepare_metadata_for_build_wheel
      self.run_setup()
    File "C:\Users\Zaid\AppData\Local\Temp\pip-build-env-ozjc6kz_\overlay\Lib\site-packages\setuptools\build_meta.py", line 267, in run_setup
      super(_BuildMetaLegacyBackend,
    File "C:\Users\Zaid\AppData\Local\Temp\pip-build-env-ozjc6kz_\overlay\Lib\site-packages\setuptools\build_meta.py", line 158, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 319, in <module>
      setup_package()
    File "setup.py", line 315, in setup_package
      setup(**metadata)
    File "C:\Users\Zaid\AppData\Local\Temp\pip-build-env-ozjc6kz_\overlay\Lib\site-packages\numpy\distutils\core.py", line 135, in setup
      config = configuration()
    File "setup.py", line 201, in configuration
      config.add_subpackage("sklearn")
    File "C:\Users\Zaid\AppData\Local\Temp\pip-build-env-ozjc6kz_\overlay\Lib\site-packages\numpy\distutils\misc_util.py", line 1016, in add_subpackage
      config_list = self.get_subpackage(subpackage_name, subpackage_path,
    File "C:\Users\Zaid\AppData\Local\Temp\pip-build-env-ozjc6kz_\overlay\Lib\site-packages\numpy\distutils\misc_util.py", line 982, in get_subpackage
      config = self._get_configuration_from_setup_py(
    File "C:\Users\Zaid\AppData\Local\Temp\pip-build-env-ozjc6kz_\overlay\Lib\site-packages\numpy\distutils\misc_util.py", line 924, in _get_configuration_from_setup_py
      config = setup_module.configuration(*args)
    File "sklearn\setup.py", line 85, in configuration
      cythonize_extensions(top_path, config)
    File "C:\Users\Zaid\AppData\Local\Temp\pip-install-hkon2hc1\scikit-learn_da5359c4d7ad4dadb4a1f14623e7a4ac\sklearn\_build_utils\__init__.py", line 47, in cythonize_extensions
      basic_check_build()
    File "C:\Users\Zaid\AppData\Local\Temp\pip-install-hkon2hc1\scikit-learn_da5359c4d7ad4dadb4a1f14623e7a4ac\sklearn\_build_utils\pre_build_helpers.py", line 113, in basic_check_build
      compile_test_program(code)
    File "C:\Users\Zaid\AppData\Local\Temp\pip-install-hkon2hc1\scikit-learn_da5359c4d7ad4dadb4a1f14623e7a4ac\sklearn\_build_utils\pre_build_helpers.py", line 70, in compile_test_program
      ccompiler.compile(
    File "G:\python\lib\distutils\_msvccompiler.py", line 323, in compile
      self.initialize()
    File "G:\python\lib\distutils\_msvccompiler.py", line 220, in initialize
      vc_env = _get_vc_env(plat_spec)
    File "C:\Users\Zaid\AppData\Local\Temp\pip-build-env-ozjc6kz_\overlay\Lib\site-packages\setuptools\msvc.py", line 316, in msvc14_get_vc_env
      return _msvc14_get_vc_env(plat_spec)
    File "C:\Users\Zaid\AppData\Local\Temp\pip-build-env-ozjc6kz_\overlay\Lib\site-packages\setuptools\msvc.py", line 270, in _msvc14_get_vc_env
      raise distutils.errors.DistutilsPlatformError(
  distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

【问题讨论】:

首先在问题正文中描述问题,而不是在标题中。并使用特殊函数格式化错误。 Python 3.10 是非常新的版本。某些模块尚未为此版本做好准备。也许最好等几个月再使用3.9 甚至3.8 Sklearn 有一些 C/C++ 代码,它需要 C/C++ 编译器,并且错误的最后一行显示了您可以获得 C/C++ 编译器的链接。 ***.com/… 【参考方案1】:

从https://visualstudio.microsoft.com/visual-cpp-build-tools/下载c++编译器 我敢肯定你自己也读过:/

【讨论】:

以上是关于无法安装 scikit-learn,但它无法在窗口 8.1 的 jupyter notebook 中的 python 3.10 中安装 [重复]的主要内容,如果未能解决你的问题,请参考以下文章

未能直接从Github在Google Colab中安装Sk-learn(scikit-learn)

无法导入 Scikit-Learn

无法在 Pycharm 中和通过苹果 m1 上的 cli 安装包 scikit-learn

无法使用 pip 1.5.6 安装 scipy、matplotlob 和 scikit-learn

将模块安装到 2.7.10 而不是 2.7.13 导致默认 python2.7.13 无法在 MAC 终端窗口上导入这些模块

无法在 Python 中安装 scikit-learn