F2PY cannot find intel fortran compiler on windows 7

北城以北 提交于 2020-01-14 03:29:06

问题


I am struggling to get F2PY working with Intel Fortran on Windows 7. This appears to be a common issue and I have attempted a number of suggestions found in other posts (described below).

A bit of information about my system:

  • Windows 7 64-bit
  • Python 2.7.11 via Enthought Canopy 32-bit (up to date as of June 12, 2016)
  • Intel Fortran 14 (Intel\Composer XE 2013 SP1) (32 and 64-bit)

After doing a bit of research see here I found that the issue may be related to the c++ runtime so I installed Microsoft Visual C++ for Python.

Still, when I attempt to build a simple test case, I receive the following error:

    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>

Here is an output of the f2py compiler check:

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

And here are some relevant system variables:

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 …

Some things I have tried:

  • Ran ifortvars.bat as suggested here and here
  • Tried various --fcompiler = intelv, intelvem, intel, intelem options (even though intelv should be the correct one)
  • Added the [IFORT] system variable above as a duplicate of [IFORT_COMPILER14] in case F2PY stumbled on the version specific key
  • Tried extending these paths down a level to: C:\Program Files (x86)\Intel\Composer XE 2013 SP1\bin\ia32 (didnt work, so reverted back)

However, I get the same result. I am puzzled that despite my path and environment variable settings, the ifort.exe cannot be found. Any ideas or guidance would be much appreciated!

Thanks, Mack


回答1:


After some further experimentation, I was able to resolve the issue and am posting the steps that worked in case it may help others with similar problems.

  1. f2py can now find Intel Fortran after setting the path to C:\Program Files (x86)\Intel\Composer XE 2013 SP1\bin\ia32 and rebooting
  2. However, after this, I received an error stating: "error unable to find vcvarsall.bat". This is the batch file with configuration settings for the Microsoft c++ for Python 2.7 runtime mentioned above. As I gathered from other posts, this is a bug in Python 2.7.11 that I was able to correct by editing the msvc9compiler.py file in the main (not numpy) distutils folder. Specifically, I hardcoded the path to this file as such in line 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 = {}
    


来源:https://stackoverflow.com/questions/37776876/f2py-cannot-find-intel-fortran-compiler-on-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!