F2PY on Win64: Unable to find vcvarsall.bat
F2py是将fortran程序(subroutine, function, module)转化成python module一个非常好用的工具。主要编译语句如下:
$ f2py -c -m python_module fortran_script.f90
编译成功之后,在python脚本中便可通过如下的语句来使用module中的attribute, method
>>>import python_module
Canopy是Enthought推出的一个类似于MATLAB界面的python科学计算集成工具,其中包含了许多科学计算经常用到的package和module(比如,numpy, matplotlib, scipy, pandas, basemap等)。Canopy 1.3在Windows64安装之后,利用f2py转换Fortran程序时会出现如下错误:
Unable to find vcvarsall.bat
Enthought官网上针对此问题给出的解决方案是安装MS Visual Studio 2008. 详见https://support.enthought.com/entries/26864394-Windows-Unable-to-find-vcvarsall-bat
但是,很遗憾。我自己安装VS2008之后,并没有解决问题。
最后在google搜索的解决方案是:(网址忘了保存)
1) 将PYTHONPATH\Lib\site-packages\numpy\distutils\fcompiler\gnu.py第331行由
raise NotImplementedError("Only MS compiler supported with gfortran on win64")
改成:
pass #raise NotImplementedError("Only MS compiler supported with gfortran on win64")
PYTHONPATH为python安装路径
2)利用如下命令编译:
$f2py -c --fcompiler=gnu95 --compiler=mingw32 -m python_module fortran_script.f90
F2PY on Win64: Unable to find vcvarsall.bat,布布扣,bubuko.com
原文:http://www.cnblogs.com/zuoer-dream/p/3604809.html