首页 > 解决方案 > (Python/VS 代码)无法安装 scipy

问题描述

我似乎无法使用 VS Code 安装 scipy。

python -m pip install scipy 收集 scipy 使用缓存的 scipy-1.5.2.tar.gz (25.4 MB) 安装构建依赖项...完成获取构建轮的要求...完成准备轮元数据...错误错误:命令错误退出状态为 1:命令:'C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\python.exe''C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib\ site-packages\pip_vendor\pep517_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\bundyjas\AppData\Local\Temp\tmpmkxabgvf' cwd: C:\Users\bundyjas\AppData\Local\Temp\pip-install-4lff1348\scipy Complete输出(195 行): setup.py:460: UserWarning: Unrecognized setuptools command ('dist_info --egg-base C:\Users\bundyjas\AppData\Local\Temp\pip-modern-metadata-j_sx_haa'),继续生成 Cython 源和扩展模板 warnings.warn("Unrecognized setuptools command ('{}'), 继续" 从 SciPy 源目录运行。lapack_opt_info: lapack_mkl_info: No module named 'numpy.distutils._msvccompiler' in numpy.distutils ; 尝试从 distutils 自定义 MSVCCompiler 库 mkl_rt 在 ['C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib', 'C:\', 'C:\Users\bundyjas\AppData\Local \Programs\Python\Python39\libs'] 不可用尝试从 distutils 自定义 MSVCCompiler 库 mkl_rt 在 ['C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib', 'C:\', 'C:\Users\bundyjas\AppData\Local\程序\Python\Python39\libs'] 不可用尝试从 distutils 自定义 MSVCCompiler 库 mkl_rt 在 ['C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib', 'C:\', 'C:\Users\bundyjas\AppData\Local\程序\Python\Python39\libs'] 不可用

openblas_lapack_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries openblas not found in ['C:\\Users\\bundyjas\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\bundyjas\\AppData\\Local\\Programs\\Python\\Python39\\libs']
get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 

'intelem', 'flang']' 自定义 GnuFCompiler 无法找到可执行文件 g77 无法找到可执行文件 f77 自定义 IntelVisualFCompiler 无法找到可执行文件 ifort 无法找到可执行文件 ifl 自定义 AbsoftFCompiler 无法找到可执行文件 f90 自定义 CompaqVisualFCompiler 无法找到可执行文件 DF 自定义 IntelItaniumVisualFCompiler 可以找不到可执行文件 efl 定制 Gnu95FCompiler 找不到可执行文件 gfortran 找不到可执行文件 f95 定制 G95FCompiler 找不到可执行文件 g95 定制 IntelEM64VisualFCompiler 定制 IntelEM64TFCompiler 找不到可执行文件 efort 找不到可执行文件 efc 定制 PGroupFlangCompiler 找不到可执行文件 flang 不知道如何在平台“nt”上编译 Fortran 代码不可用

openblas_clapack_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries openblas,lapack not found in ['C:\\Users\\bundyjas\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\bundyjas\\AppData\\Local\\Programs\\Python\\Python39\\libs']
  NOT AVAILABLE

flame_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries flame not found in ['C:\\Users\\bundyjas\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\bundyjas\\AppData\\Local\\Programs\\Python\\Python39\\libs']
  NOT AVAILABLE

atlas_3_10_threads_info:
Setting PTATLAS=ATLAS
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries tatlas,tatlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries tatlas,tatlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\libs
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries tatlas,tatlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\libs
<class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
  NOT AVAILABLE

atlas_3_10_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries satlas,satlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries satlas,satlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\libs
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries satlas,satlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\libs
<class 'numpy.distutils.system_info.atlas_3_10_info'>
  NOT AVAILABLE

atlas_threads_info:
Setting PTATLAS=ATLAS
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries ptf77blas,ptcblas,atlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries ptf77blas,ptcblas,atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\libs
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries ptf77blas,ptcblas,atlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\libs        
<class 'numpy.distutils.system_info.atlas_threads_info'>
  NOT AVAILABLE

atlas_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries f77blas,cblas,atlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries f77blas,cblas,atlas not found in C:\
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack_atlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\libs
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries f77blas,cblas,atlas not found in C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\libs
<class 'numpy.distutils.system_info.atlas_info'>
  NOT AVAILABLE

accelerate_info:
  NOT AVAILABLE

lapack_info:
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
  libraries lapack not found in ['C:\\Users\\bundyjas\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\', 'C:\\Users\\bundyjas\\AppData\\Local\\Programs\\Python\\Python39\\libs']
  NOT AVAILABLE

C:\Users\bundyjas\AppData\Local\Temp\pip-build-env-eitrbrks\overlay\Lib\site-packages\numpy\distutils\system_info.py:1712: UserWarning:
    Lapack (http://www.netlib.org/lapack/) libraries not found.
    Directories to search for the libraries can be specified in the
    numpy/distutils/site.cfg file (section [lapack]) or by setting
    the LAPACK environment variable.
  if getattr(self, '_calc_info_{}'.format(lapack))():
lapack_src_info:
  NOT AVAILABLE

C:\Users\bundyjas\AppData\Local\Temp\pip-build-env-eitrbrks\overlay\Lib\site-packages\numpy\distutils\system_info.py:1712: UserWarning:
    Lapack (http://www.netlib.org/lapack/) sources not found.
    Directories to search for the sources can be specified in the
    numpy/distutils/site.cfg file (section [lapack_src]) or by setting
    the LAPACK_SRC environment variable.
  if getattr(self, '_calc_info_{}'.format(lapack))():
  NOT AVAILABLE

Traceback (most recent call last):
  File "C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 280, in <module>
    main()
  File "C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 263, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 133, in prepare_metadata_for_build_wheel
    return hook(metadata_directory, config_settings)
  File "C:\Users\bundyjas\AppData\Local\Temp\pip-build-env-eitrbrks\overlay\Lib\site-packages\setuptools\build_meta.py", line 161, in prepare_metadata_for_build_wheel
    self.run_setup()
  File "C:\Users\bundyjas\AppData\Local\Temp\pip-build-env-eitrbrks\overlay\Lib\site-packages\setuptools\build_meta.py", line 253, in run_setup
    super(_BuildMetaLegacyBackend,
  File "C:\Users\bundyjas\AppData\Local\Temp\pip-build-env-eitrbrks\overlay\Lib\site-packages\setuptools\build_meta.py", line 145, in run_setup
    exec(compile(code, __file__, 'exec'), locals())
  File "setup.py", line 583, in <module>
    setup_package()
  File "setup.py", line 579, in setup_package
    setup(**metadata)
  File "C:\Users\bundyjas\AppData\Local\Temp\pip-build-env-eitrbrks\overlay\Lib\site-packages\numpy\distutils\core.py", line 137, in setup
    config = configuration()
  File "setup.py", line 477, in configuration
    raise NotFoundError(msg)
numpy.distutils.system_info.NotFoundError: No lapack/blas resources found.
----------------------------------------

错误:命令出错,退出状态为 1:'C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\python.exe''C:\Users\bundyjas\AppData\Local\Programs\Python\Python39\ lib\site-packages\pip_vendor\pep517_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\bundyjas\AppData\Local\Temp\tmpmkxabgvf' 检查日志以获取完整的命令输出。

标签: pythonvisual-studio-codescipy

解决方案


从源代码安装 scipy非常苛刻,不推荐使用,尤其是在 Windows 上。您的日志已经表明需要 C/C++/Fortran 编译器,后者用于 OpenBLAS。(在 1.0 之前,有几年没有官方二进制版本!)

当没有找到合适的预制二进制文件时,从源代码安装会发生,就像你的情况一样。

这里的原因:您使用的是 Python 3.9,它太新了(10 月 5 日:现在 < 2 周)。目前还没有官方的预制 scipy 版本暗示

选择 Python <= 3.8。(相信我:你不想在 Windows 上从源代码安装)。

(这与 VS Code 完全无关/正交)


推荐阅读