F2PY在windows 7上找不到“英特尔fortran编译器”

2024-10-01 19:15:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在努力让F2PY在windows7上与intelfortran一起工作。这似乎是一个常见的问题,我已经尝试了在其他帖子中找到的一些建议(如下所述)。在

关于我的系统的一些信息:

  • Windows 7 64位
  • Python2.7.11,通过32位的enthough Canopy(截至6月的最新版本 2016年12月12日)
  • 英特尔Fortran 14(Intel\Composer XE 2013 SP1)(32位和64位)

在做了一点研究see here后,我发现这个问题可能与C++运行时相关,所以我为Python安装了微软Visual C++。在

不过,当我试图构建一个简单的测试用例时,我收到以下错误:

    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编译器检查的输出:

^{pr2}$

下面是一些相关的系统变量:

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 …

我试过的一些事情:

  • 跑ifortvars.bat如建议herehere
  • 尝试了各种--fcompiler=intelv,intelv,intel,intel选项(即使intelv应该是正确的)
  • 添加了上面的[IFORT]系统变量作为 [IFORT_COMPILER14]以防F2PY碰到特定于版本的键
  • 尝试将这些路径向下扩展到:C:\Program Files (x86)\Intel\Composer XE 2013 SP1\bin\ia32(无效,因此已还原 背面)

然而,我得到了同样的结果。我很困惑,尽管我设置了路径和环境变量,但是ifort.exe文件找不到。任何想法或指导将不胜感激!在

谢谢, 麦克


Tags: runinpybuildliblocallineusers
1条回答
网友
1楼 · 发布于 2024-10-01 19:15:07

经过进一步的实验,我终于解决了这个问题,并发布了一些有效的步骤,以防它可以帮助其他人解决类似的问题。在

  1. f2py现在可以在将路径设置为C:\Program Files(x86)\Intel\Composer XE 2013 SP1\bin\ia32并重新启动后找到“英特尔Fortran”
  2. 然而,在这之后,我收到了一个错误:“错误无法找到vcvarsall.bat公司". 这是上面提到的microsoftc++forpython2.7运行时配置设置的批处理文件。正如我从其他帖子中收集到的,这是Python2.7.11中的一个bug,我可以通过编辑msvc9来纠正它编译器.py主(不是numpy)distutils文件夹中的文件。具体地说,我在第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 = {}
    

相关问题 更多 >

    热门问题