2011年10月13日 星期四 10:57
我下载了
并安装到python2.6中
但是为什么在我的cmddos窗口或者bat文件中说找不到f2py呢?
我的编译命令在bat文件中:
f2py -c SFoo.f90 -m SFoo --fcompiler=Compaqv --compiler=msvc
我在环境变量中已经加入了C:\python2.6
但是系统说: 'f2py' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
2011年10月13日 星期四 11:24
f2py是放在c:\python2.6\scripts下的,其文件名为f2py.py,因此你需要PATH中有c:\python2.6\scripts,并且用f2py.py运行。不要省略扩展名。
2011年10月13日 星期四 11:29
经过查阅,发现不用2.x/F2PY-2-latest.win32.exe Numpy安装后自己带了f2py,但是现在有个问题
python C:\Python26\Scripts\f2py.py -c -m SFoo SFoo.f90
运行后出现以下错误,不能生成相应的文件
F:\Computer_Language\Python\Example\Fortran\Python_call_fortran_subroutine>pytho
n C:\Python26\Scripts\f2py.py -c -m SFoo SFoo.f90
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler opti
ons
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler opt
ions
running build_src
build_src
building extension "SFoo" sources
f2py options: []
f2py:> c:\docume~1\zengxi~1\locals~1\temp\tmp4vrnyq\src.win32-2.6\SFoomodule.c
creating c:\docume~1\zengxi~1\locals~1\temp\tmp4vrnyq
creating c:\docume~1\zengxi~1\locals~1\temp\tmp4vrnyq\src.win32-2.6
Reading fortran codes...
Reading file 'SFoo.f90' (format:free)
Post-processing...
Block: SFoo
Block: foo
Post-processing (stage 2)...
Building modules...
Building module "SFoo"...
Constructing wrapper function "foo"...
foo(a)
Wrote C/API module "SFoo" to file "c:\docume~1\zengxi~1\locals~1\temp\tm
p4vrnyq\src.win32-2.6\SFoomodule.c"
adding 'c:\docume~1\zengxi~1\locals~1\temp\tmp4vrnyq\src.win32-2.6\fortranobje
ct.c' to sources.
adding 'c:\docume~1\zengxi~1\locals~1\temp\tmp4vrnyq\src.win32-2.6' to include
_dirs.
copying C:\Python26\lib\site-packages\numpy\f2py\src\fortranobject.c -> c:\docum
e~1\zengxi~1\locals~1\temp\tmp4vrnyq\src.win32-2.6
copying C:\Python26\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\docum
e~1\zengxi~1\locals~1\temp\tmp4vrnyq\src.win32-2.6
build_src: building npy-pkg config files
running build_ext
No module named msvccompiler in numpy.distutils; trying from distutils
customize MSVCCompiler
customize MSVCCompiler using build_ext
customize GnuFCompiler
Could not locate executable g77
Found executable C:\Program Files\Microsoft Visual Studio\DF98\BIN\f77.exe
gnu: no Fortran 90 compiler found
gnu: no Fortran 90 compiler found
Found executable C:\Program Files\Microsoft Visual Studio\DF98\BIN\f77.exe
customize IntelVisualFCompiler
Could not locate executable ifort
Could not locate executable ifl
customize AbsoftFCompiler
Found executable C:\Program Files\Microsoft Visual Studio\DF98\BIN\f90.exe
Found executable C:\Program Files\Microsoft Visual Studio\DF98\BIN\f90.exe
customize CompaqVisualFCompiler
Found executable C:\Program Files\Microsoft Visual Studio\DF98\BIN\DF.exe
Found executable C:\Program Files\Microsoft Visual Studio\DF98\BIN\DF.exe
customize CompaqVisualFCompiler
customize CompaqVisualFCompiler using build_ext
building 'SFoo' extension
compiling C sources
error: Unable to find vcvarsall.bat
2011年10月14日 星期五 08:45
以前也用过,但是当时Fortran没太多用就没再继续。
http://www.zeuux.org/group/scipython/bbs/content/50953/
当时是可以编译的,也可以运行,用的是gfortran-windows-20110214.exe
你可以先试一下f2py的例子,看看可不可以
To check if F2PY is installed correctly, run
f2py
without any arguments. This should print out the usage information of the f2py program.
Next, try out the following three steps:
Create a Fortran file hello.f that contains:
C File hello.f subroutine foo (a) integer a print*, "Hello from Fortran!" print*, "a=",a end
f2py -c -m hello hello.fThis will build an extension module hello.so (or hello.sl, or hello.pyd, etc. depending on your platform) into the current directory.
Now in Python try:
>>> import hello >>> print hello.__doc__ >>> print hello.foo.__doc__ >>> hello.foo(4) Hello from Fortran! a= 4 >>>
Zeuux © 2024
京ICP备05028076号