Skip to content

f2py - error in compaq.py when running "f2py -c --help-fcompiler" #10162

@tdgskinner

Description

@tdgskinner

I'm trying to use f2py (under anaconda 2, windows 7 64bit, python 2.7.13, numpy 1.13.1) but I run into the following error repeatedly, even when simply trying to list available compilers:

(C:\Users\UserName\Anaconda2) C:\Users\UserName\Desktop\fortran>f2py -c --help-fco
mpiler

(C:\Users\UserName\Anaconda2) C:\Users\UserName\Desktop\fortran>call "C:\Users\UserName\
Anaconda2\Scripts\\..\python.exe" "C:\Users\UserName\Anaconda2\Scripts\\f2py
.py" -c --help-fcompiler
Unexpected ValueError in C:\Users\UserName\Anaconda2\lib\site-packages\numpy\dist
utils\fcompiler\compaq.pyc
Traceback (most recent call last):
  File "C:\Users\UserName\Anaconda2\Scripts\\f2py.py", line 28, in <module>
    main()
  File "C:\Users\UserName\Anaconda2\lib\site-packages\numpy\f2py\f2py2e.py", line
 648, in main
    run_compile()
  File "C:\Users\UserName\Anaconda2\lib\site-packages\numpy\f2py\f2py2e.py", line
 633, in run_compile
    setup(ext_modules=[ext])
  File "C:\Users\UserName\Anaconda2\lib\site-packages\numpy\distutils\core.py", l
ine 169, in setup
    return old_setup(**new_attr)
  File "C:\Users\UserName\Anaconda2\lib\distutils\core.py", line 137, in setup
    ok = dist.parse_command_line()
  File "C:\Users\UserName\Anaconda2\lib\distutils\dist.py", line 467, in parse_co
mmand_line
    args = self._parse_command_opts(parser, args)
  File "C:\Users\UserName\Anaconda2\lib\distutils\dist.py", line 576, in _parse_c
ommand_opts
    func()
  File "C:\Users\UserName\Anaconda2\lib\site-packages\numpy\distutils\command\con
fig_compiler.py", line 15, in show_fortran_compilers
    show_fcompilers(dist)
  File "C:\Users\UserName\Anaconda2\lib\site-packages\numpy\distutils\fcompiler\_
_init__.py", line 882, in show_fcompilers
    load_all_fcompiler_classes()
  File "C:\Users\UserName\Anaconda2\lib\site-packages\numpy\distutils\fcompiler\_
_init__.py", line 740, in load_all_fcompiler_classes
    __import__ (module_name)
  File "C:\Users\UserName\Anaconda2\lib\site-packages\numpy\distutils\fcompiler\c
ompaq.py", line 57, in <module>
    class CompaqVisualFCompiler(FCompiler):
  File "C:\Users\UserName\Anaconda2\lib\site-packages\numpy\distutils\fcompiler\c
ompaq.py", line 100, in CompaqVisualFCompiler
    raise e
ValueError: [u'path', u'include']

(C:\Users\UserName\Anaconda2) C:\Users\UserName\Desktop\fortran>

I've installed minGW for anaconda (via conda install mingw), so it should detect and run that. I'm not too sure but it seems like it's trying to find the compaq one instead and failing at that? Here's the relevant section of compaq.py (line 100 is the final line):

if sys.platform=='win32':
        from numpy.distutils.msvccompiler import MSVCCompiler

        try:
            m = MSVCCompiler()
            m.initialize()
            ar_exe = m.lib
        except DistutilsPlatformError:
            pass
        except AttributeError:
            msg = get_exception()
            if '_MSVCCompiler__root' in str(msg):
                print('Ignoring "%s" (I think it is msvccompiler.py bug)' % (msg))
            else:
                raise
        except IOError:
            e = get_exception()
            if not "vcvarsall.bat" in str(e):
                print("Unexpected IOError in", __file__)
                raise e
        except ValueError:
            e = get_exception()
            if not "path']" in str(e):
                print("Unexpected ValueError in", __file__)
                raise e

stackexchange post

Also, if I try to use the method to compile from within python, I get a file permission error for writing into the temporary folder. Running the following in spyder:

import os
import numpy as np
from numpy import f2py
os.chdir(r'C:\Users\UserName\Desktop\fortran')
with open('test.f90') as fortFile:
    sourcecode = fortFile.read()
f2py.compile(sourcecode, modulename='add1')

returns this:

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 "add1" sources
f2py options: []
f2py:> c:\users\UserName\appdata\local\temp\tmpcseja7\src.win-amd64-2.7\add1module.c
creating c:\users\UserName\appdata\local\temp\tmpcseja7\src.win-amd64-2.7
Reading fortran codes...
Post-processing...
Post-processing (stage 2)...
Building modules...
IOError: [Errno 13] Permission denied: 'c:\\users\\UserName\\appdata\\local\\temp\\tmpqc_9rz.f'. Skipping file "c:\users\UserName\appdata\local\temp\tmpqc_9rz.f".
error: f2py target file 'c:\\users\\UserName\\appdata\\local\\temp\\tmpcseja7\\src.win-amd64-2.7\\add1module.c' not generated

I've checked that I don't have weird permissions set on my temp folder.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions