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

时间:2018-03-01 19:23:40

标签: python fortran f2py

我正在尝试使用以下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

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

1 个答案:

答案 0 :(得分:1)

看起来好像它想要Microsoft Visual C ++并且gcc不会这样做。您可以下载VS2017 Community Edition,确保执行非默认安装并选择C ++组件。 https://software.intel.com/en-us/articles/intel-c-fortran-compilers-for-windows-integration-into-microsoft-visual-studio-2017在英特尔编译器的上下文中对此进行了讨论,但VS配置信息也是相关的。