我正在努力让F2PY在Windows 7上使用英特尔Fortran。这似乎是一个常见问题,我尝试了其他帖子中提到的一些建议(如下所述)。
关于我的系统的一些信息:
在做了一些研究之后see here我发现问题可能与c ++运行时有关,所以我安装了Microsoft Visual C ++ for Python。
但是,当我尝试构建一个简单的测试用例时,我收到以下错误:
D:\python stuff\enthought_ course\demo\f2py_fcopy>f2py -c --fcompiler=intelv --c
ompiler=msvc -m fcopy fcopy.f
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 "fcopy" sources
f2py options: []
f2py:> c:\users\mshippen\appdata\local\temp\tmpthkqug\src.win32-2.7\fcopymodule.
c
creating c:\users\mshippen\appdata\local\temp\tmpthkqug\src.win32-2.7
Reading fortran codes...
Reading file 'fcopy.f' (format:fix,strict)
Post-processing...
Block: fcopy
Block: fcopy
Post-processing (stage 2)...
Building modules...
Building module "fcopy"...
Constructing wrapper function "fcopy"...
getarrdims:warning: assumed shape array, using 0 instead of '*'
getarrdims:warning: assumed shape array, using 0 instead of '*'
fcopy(ain,n,aout)
Wrote C/API module "fcopy" to file "c:\users\mshippen\appdata\local\temp
\tmpthkqug\src.win32-2.7\fcopymodule.c"
adding 'c:\users\mshippen\appdata\local\temp\tmpthkqug\src.win32-2.7\fortranob
ject.c' to sources.
adding 'c:\users\mshippen\appdata\local\temp\tmpthkqug\src.win32-2.7' to inclu
de_dirs.
copying C:\Users\mshippen\AppData\Local\Enthought\Canopy32\User\lib\site-package
s\numpy\f2py\src\fortranobject.c -> c:\users\mshippen\appdata\local\temp\tmpthkq
ug\src.win32-2.7
copying C:\Users\mshippen\AppData\Local\Enthought\Canopy32\User\lib\site-package
s\numpy\f2py\src\fortranobject.h -> c:\users\mshippen\appdata\local\temp\tmpthkq
ug\src.win32-2.7
build_src: building npy-pkg config files
running build_ext
customize MSVCCompiler
customize MSVCCompiler using build_ext
customize IntelVisualFCompiler
Could not locate executable ifort
Could not locate executable ifl
Traceback (most recent call last):
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\User\Scripts\f2py-scr
ipt.py", line 28, in <module>
main()
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\User\lib\site-package
s\numpy\f2py\f2py2e.py", line 648, in main
run_compile()
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\User\lib\site-package
s\numpy\f2py\f2py2e.py", line 633, in run_compile
setup(ext_modules=[ext])
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\User\lib\site-package
s\numpy\distutils\core.py", line 169, in setup
return old_setup(**new_attr)
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\App\appdata\canopy-1.
7.1.3323.win-x86\lib\distutils\core.py", line 151, in setup
dist.run_commands()
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\App\appdata\canopy-1.
7.1.3323.win-x86\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\App\appdata\canopy-1.
7.1.3323.win-x86\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\User\lib\site-package
s\numpy\distutils\command\build.py", line 47, in run
old_build.run(self)
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\App\appdata\canopy-1.
7.1.3323.win-x86\lib\distutils\command\build.py", line 127, in run
self.run_command(cmd_name)
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\App\appdata\canopy-1.
7.1.3323.win-x86\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\App\appdata\canopy-1.
7.1.3323.win-x86\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\User\lib\site-package
s\numpy\distutils\command\build_ext.py", line 222, in run
fcompiler.customize(self.distribution)
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\User\lib\site-package
s\numpy\distutils\fcompiler\__init__.py", line 464, in customize
self.find_executables()
File "C:\Users\mshippen\AppData\Local\Enthought\Canopy32\User\lib\site-package
s\numpy\distutils\fcompiler\__init__.py", line 354, in find_executables
raise CompilerNotFound('%s: f90 nor f77' % ctype)
numpy.distutils.fcompiler.CompilerNotFound: intelv: f90 nor f77
D:\python stuff\enthought_ course\demo\f2py_fcopy>
以下是f2py编译器检查的输出:
D:\python stuff\enthought_ course\demo\f2py_fcopy>ff2py -c --help-fcompiler
Fortran compilers found:
Compilers available for this platform, but not found:
--fcompiler=absoft Absoft Corp Fortran Compiler
--fcompiler=compaqv DIGITAL or Compaq Visual Fortran Compiler
--fcompiler=g95 G95 Fortran Compiler
--fcompiler=gnu GNU Fortran 77 compiler
--fcompiler=gnu95 GNU Fortran 95 compiler
--fcompiler=intelem Intel Fortran Compiler for 64-bit apps
--fcompiler=intelev Intel Visual Fortran Compiler for Itanium apps
--fcompiler=intelv Intel Visual Fortran Compiler for 32-bit apps
--fcompiler=intelvem Intel Visual Fortran Compiler for 64-bit apps
Compilers not available on this platform:
--fcompiler=compaq Compaq Fortran Compiler
--fcompiler=hpux HP Fortran 90 Compiler
--fcompiler=ibm IBM XL Fortran Compiler
--fcompiler=intel Intel Fortran Compiler for 32-bit apps
--fcompiler=intele Intel Fortran Compiler for Itanium apps
--fcompiler=lahey Lahey/Fujitsu Fortran 95 Compiler
--fcompiler=mips MIPSpro Fortran Compiler
--fcompiler=nag NAGWare Fortran 95 Compiler
--fcompiler=none Fake Fortran compiler
--fcompiler=pathf95 PathScale Fortran Compiler
--fcompiler=pg Portland Group Fortran Compiler
--fcompiler=sun Sun or Forte Fortran 95 Compiler
--fcompiler=vast Pacific-Sierra Research Fortran 90 Compiler
For compiler details, run 'config_fc --verbose' setup command.
Removing build directory c:\users\mshippen\appdata\local\temp\tmpiopwe2
以下是一些相关的系统变量:
IFORT=C:\Program Files (x86)\Intel\Composer XE 2013 SP1\
IFORT_COMPILER14=C:\Program Files (x86)\Intel\Composer XE 2013 SP1\
INTEL_DEV_REDIST=C:\Program Files (x86)\Common Files\Intel\Shared Libraries\
INTEL_LICENSE_FILE=C:\Program Files (x86)\Common Files\Intel\Licenses
Path=C:\Users\mshippen\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\WinSDK\Bin; C:\Program Files (x86)\Intel\Composer XE 2013 SP1\bin\; etc …
我尝试过的一些事情:
然而,我得到了相同的结果。我很困惑,尽管我的路径和环境变量设置,无法找到ifort.exe。任何想法或指导将不胜感激!
谢谢, 麦克
答案 0 :(得分:1)
经过一些进一步的实验,我能够解决问题并发布有效的步骤,以防其他人遇到类似问题。
但是,在此之后,我收到一条错误消息:“错误无法找到vcvarsall.bat”。这是包含上面提到的Microsoft c ++ for Python 2.7运行时配置设置的批处理文件。正如我从其他帖子中收集到的,这是Python 2.7.11中的一个错误,我可以通过编辑main(非numpy)distutils文件夹中的msvc9compiler.py文件来纠正它。具体来说,我在第267行硬编码了这个文件的路径:
def query_vcvarsall(version, arch="x86"):
"""Launch vcvarsall.bat and read the settings from its environment """
vcvarsall = find_vcvarsall(version)
vcvarsall = "C:/Users/mshippen/AppData/Local/Programs/Common/Microsoft/Visual C++ for Python/9.0/vcvarsall.bat"
interesting = set(("include", "lib", "libpath", "path"))
result = {}
答案 1 :(得分:0)
我遇到了类似的问题。 (Windows 10用户)
我最终只为Windows安装了mingw32 64位。
我认为我使用了以下命令:python pip install mingw32
然后我对vcvarsall遇到了类似的问题
只需确保逃避\\ fpath
有关vcvarsall问题的更多帮助: here