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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了编译f2py代码时找不到vscvarsall.bat相关的知识,希望对你有一定的参考价值。

我正在尝试使用以下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 'buildsrc.win-amd64-3.6uildsrc.win-amd64-3.6fortranobject.c' to sources.
  adding 'buildsrc.win-amd64-3.6uildsrc.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:MinGWingfortran.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,确保执行非默认安装并选择C ++组件。 https://software.intel.com/en-us/articles/intel-c-fortran-compilers-for-windows-integration-into-microsoft-visual-studio-2017在英特尔编译器的背景下讨论了这一点,但VS配置信息也是相关的。

以上是关于编译f2py代码时找不到vscvarsall.bat的主要内容,如果未能解决你的问题,请参考以下文章

编译时找不到动态库

在 Windows 上使用 MinGW 编译 C++ 时找不到 omp.h

IDEA 高版本(2020.3 以上) lombok 不报错,但是编译时找不到符号问题解决, lombok 无法运行

在 python 代码中使用 f2py 模块时的问题

f2py:找不到命令

使用 Cython 编译时找不到库文件