Python は初めてで、既存の Fortran コードを使用して Python から実行できるようにしたいと考えています。オンラインの指示に従って、F2PY を使用して小さな「Hello world」Fortran プログラムをコンパイルしようとしています。
私はWindowsで作業しています。これまでのところ、Python 2.7.3、NumPy 1.6.1、SciPy 10.1、および MinGW 4.8 をインストールしました。
それから私は(とりわけ)試しました
f2py.py -c --compiler=mingw32 --fcompiler=gnu95 -m foo foo.f90
これは、無効なバージョン番号を報告します。
ValueError: 無効なバージョン番号 '4'。
誰かが何がうまくいかないのか、これを実行するために何を変更する必要があるのか を提案できれば、私は最も感謝しています. F2PY からの完全な出力は次のとおりです。
D:\python\fortran2>f2py.py -c --compiler=mingw32 --fcompiler=gnu95 -m foo foo.f90
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "foo" sources
f2py options: []
f2py:> c:\docume~1\ajr\locals~1\temp\tmpwvnr2c\src.win32-2.7\foomodule.c
creating c:\docume~1\ajr\locals~1\temp\tmpwvnr2c
creating c:\docume~1\ajr\locals~1\temp\tmpwvnr2c\src.win32-2.7
Reading fortran codes...
Reading file 'foo.f90' (format:free)
Post-processing...
Block: foo
Block: hello
Post-processing (stage 2)...
Building modules...
Building module "foo"...
Constructing wrapper function "hello"...
hello()
Wrote C/API module "foo" to file "c:\docume~1\ajr\locals~1\temp\tmpwvnr2c\src.win32-2.7\foomodule.c"
adding 'c:\docume~1\ajr\locals~1\temp\tmpwvnr2c\src.win32-2.7\fortranobject.c' to sources.
adding 'c:\docume~1\ajr\locals~1\temp\tmpwvnr2c\src.win32-2.7' to include_dirs.
copying C:\Python27\lib\site-packages\numpy\f2py\src\fortranobject.c -> c:\docume~1\ajr\locals~1\temp\tmpwvnr2c\src.win32-2.7
copying C:\Python27\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\docume~1\ajr\locals~1\temp\tmpwvnr2c\src.win32-2.7
build_src: building npy-pkg config files
running build_ext
Traceback (most recent call last):
File "c:\python27\scripts\f2py.py", line 24, in <module>
main()
File "C:\Python27\lib\site-packages\numpy\f2py\f2py2e.py", line 588, in main
run_compile()
File "C:\Python27\lib\site-packages\numpy\f2py\f2py2e.py", line 574, in run_compile
setup(ext_modules = [ext])
File "C:\Python27\lib\site-packages\numpy\distutils\core.py", line 186, in setup
return old_setup(**new_attr)
File "C:\Python27\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\site-packages\numpy\distutils\command\build.py", line 37, in run
old_build.run(self)
File "C:\Python27\lib\distutils\command\build.py", line 127, in run
self.run_command(cmd_name)
File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\site-packages\numpy\distutils\command\build_ext.py", line 92, in run
force=self.force)
File "C:\Python27\lib\site-packages\numpy\distutils\ccompiler.py", line 556, in new_compiler
compiler = klass(None, dry_run, force)
File "C:\Python27\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 127, in __init__
elif self.gcc_version < "4.":
File "C:\Python27\lib\distutils\version.py", line 138, in __cmp__
other = StrictVersion(other)
File "C:\Python27\lib\distutils\version.py", line 40, in __init__
self.parse(vstring)
File "C:\Python27\lib\distutils\version.py", line 107, in parse
raise ValueError, "invalid version number '%s'" % vstring
ValueError: invalid version number '4.'