vscvarsall.bat编译f2py代码时未找到

vscvarsall.bat not found when compiling f2py code

我正在尝试按照教授的指示使用以下 python 脚本(称为 build_f2py_modules.py)编译一些 f2py 代码,我正在使用 python 3.6 和 windows 10 64 位:

from numpy.distutils.core import Extension
ext = Extension(name='Test',
    sources=['Sigma.f95'])

if __name__ == '__main__':
    from numpy.distutils.core import setup
    setup(name='f2py_example',
        ext_modules =[ext])

我运行它在命令提示符下使用以下命令:

python build_f2py_modules.py build_ext

我收到以下错误:

running build_ext
running build_src
build_src
building extension "Test" sources
f2py options: []
  adding 'build\src.win-amd64-3.6\build\src.win-amd64-3.6\fortranobject.c' to sources.
  adding 'build\src.win-amd64-3.6\build\src.win-amd64-3.6' to include_dirs.
build_src: building npy-pkg config files
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
customize MSVCCompiler
customize MSVCCompiler using build_ext
get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
customize GnuFCompiler
Could not locate executable g77
Could not locate executable f77
customize IntelVisualFCompiler
Could not locate executable ifort
Could not locate executable ifl
customize AbsoftFCompiler
Could not locate executable f90
customize CompaqVisualFCompiler
Could not locate executable DF
customize IntelItaniumVisualFCompiler
Could not locate executable efl
customize Gnu95FCompiler
Found executable C:\MinGW\bin\gfortran.exe
customize Gnu95FCompiler
customize Gnu95FCompiler using build_ext
building 'Test' extension
compiling C sources
error: Unable to find vcvarsall.bat

我需要下载一些东西吗?任何帮助将不胜感激

看起来好像它需要 Microsoft Visual C++ 而 gcc 不会。您或许可以下载 VS2017 Community Edition,确保进行 non-default 安装并选择 C++ 组件。 https://software.intel.com/en-us/articles/intel-c-fortran-compilers-for-windows-integration-into-microsoft-visual-studio-2017 在 Intel 编译器的上下文中讨论了这一点,但 VS 配置信息也相关。