0

I have Python 2.7, Numpy, and gfortran installed on my Windows 7 machine.

Running

python c:\Python27\Scripts\f2py.py -c --fcompiler=gnu95 --compiler=mingw32 -m hello hello.f

gives an error

objdump.exe: 'C:\WINDOWS\system32\python27.dll': No such file

There does exist file c:\MinGW64\bin\python27.dll , but I am unable to copy it to C:\WINDOWS\system32 . That directory is write-protected.

The full output is

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 "hello" sources
f2py options: []
f2py:> c:\users\myname\appdata\local\temp\tmp2pepoe\src.win-amd64-2.7\hellomodule.c
creating c:\users\myname\appdata\local\temp\tmp2pepoe
creating c:\users\myname\appdata\local\temp\tmp2pepoe\src.win-amd64-2.7
Reading fortran codes...
    Reading file 'hello.f' (format:fix,strict)
Post-processing...
    Block: hello
            Block: foo
Post-processing (stage 2)...
Building modules...
    Building module "hello"...
        Constructing wrapper function "foo"...
          foo(a)
    Wrote C/API module "hello" to file "c:\users\myname\appdata\local\temp\tmp2pepoe\src.win-amd64-2.7\hellomodule.c"
  adding 'c:\users\myname\appdata\local\temp\tmp2pepoe\src.win-amd64-2.7\fortranobject.c' to sources.
  adding 'c:\users\myname\appdata\local\temp\tmp2pepoe\src.win-amd64-2.7' to include_dirs.
copying c:\python27\lib\site-packages\numpy\f2py\src\fortranobject.c -> c:\users\myname\appdata\local\temp\tmp2pepoe\src.win-amd64-2.7
copying c:\python27\lib\site-packages\numpy\f2py\src\fortranobject.h -> c:\users\myname\appdata\local\temp\tmp2pepoe\src.win-amd64-2.7
build_src: building npy-pkg config files
running build_ext
Looking for python27.dll
Building import library (arch=AMD64): "c:\python27\libs\libpython27.a" (from C:\WINDOWS\system32\python27.dll)
objdump.exe: 'C:\WINDOWS\system32\python27.dll': No such file
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 91, in __init__
    build_import_library()
  File "c:\python27\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 299, in build_import_library
    return _build_import_library_amd64()
  File "c:\python27\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 320, in _build_import_library_amd64
    generate_def(dll_file, def_file)
  File "c:\python27\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 269, in generate_def
    if i == len(dump):
UnboundLocalError: local variable 'i' referenced before assignment
Fortranner
  • 2,525
  • 2
  • 22
  • 25
  • I don't have any specific advice for this, but recently got this working with the same setup as you (python 2.7/gfortran/win7). I used the anaconda python distribution which was pretty convenient because mingw and gfortran were bundled so there wasn't anything to configure (although there was one bug which was pretty easy to fix). – JohnE Apr 05 '15 at 21:11
  • Thanks for the anaconda suggestion. – Fortranner Apr 06 '15 at 13:57

0 Answers0