Python用tar.gz文件安装时出现错误:No module named 'numpy.distutils._msvccompiler' in numpy.distutils及Unable to find vcvarsall.bat

系统win10 64位,python版本3.7.4。

在网上下载了scikit-learn-0.22.tar,解压后利用python setup.py install进行安装时报错。

代码如下:

PS C:\Users\TH.Liu> cd E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22
PS E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22> python setup.py install
Partial import of sklearn during the build process.
E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'project_urls'
  warnings.warn(msg)
E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'python_requires'
  warnings.warn(msg)
E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'install_requires'
  warnings.warn(msg)
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
Traceback (most recent call last):
  File "setup.py", line 303, in <module>
    setup_package()
  File "setup.py", line 299, in setup_package
    setup(**metadata)
  File "E:\python\lib\site-packages\numpy\distutils\core.py", line 137, in setup
    config = configuration()
  File "setup.py", line 182, in configuration
    config.add_subpackage('sklearn')
  File "E:\python\lib\site-packages\numpy\distutils\misc_util.py", line 1035, in add_subpackage
    caller_level = 2)
  File "E:\python\lib\site-packages\numpy\distutils\misc_util.py", line 1004, in get_subpackage
    caller_level = caller_level + 1)
  File "E:\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 86, in configuration
    cythonize_extensions(top_path, config)
  File "E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22\sklearn\_build_utils\__init__.py", line 50, in cythonize_extensions
    basic_check_build()
  File "E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22\sklearn\_build_utils\pre_build_helpers.py", line 70, in basic_check_build
    compile_test_program(code)
  File "E:\python\Scripts\scikit-learn-0.22\scikit-learn-0.22\sklearn\_build_utils\pre_build_helpers.py", line 40, in compile_test_program
    extra_postargs=extra_postargs)
  File "E:\python\lib\distutils\_msvccompiler.py", line 346, in compile
    self.initialize()
  File "E:\python\lib\distutils\_msvccompiler.py", line 239, in initialize
    vc_env = _get_vc_env(plat_spec)
  File "E:\python\lib\distutils\_msvccompiler.py", line 135, in _get_vc_env
    raise DistutilsPlatformError("Unable to find vcvarsall.bat")
distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat

实际上,这俩错误我都在网上找过许多解决方式,但都没有用。下载了VS2010并尝试过在cmd中设置VS90COMNTOOLS =%VS100COMNTOOLS%,依然无效。

抱着最后的希望来这里求助……希望能得到解决。

————————————————————

2019.12.17 更新:
在安装了VS2015之后,vcvarsall.bat的问题消失了,剩下的只有:

E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'project_urls'
  warnings.warn(msg)
E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'python_requires'
  warnings.warn(msg)
E:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'install_requires'
  warnings.warn(msg)
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils

这些问题了。
大家说PowerShell容易出BUG,我换用CMD后依旧如此。
我依旧没有找到这些报错的解决方案,希望得到大佬的帮助!

Cointr
Prune丶 更新:
2 个月之前 回复

1个回答

可以去scikit-learn 官网看看,https://scikit-learn.org/stable/install.html
离线安装需要依赖的

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问