Question

I am trying to make a wrapper for one of my fortran programs using f2py. My fortran program uses external libraries and when I try to link them I get an error saying:

gfortran:f77: /var/folders/46/l1mrxgls07s6tpwb6tgpvhpr0000gn/T/tmpPCM7Ne/src.macosx-10.9-intel-2.7/progs-f2pywrappers.f
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/bin/f2py", line 24, in <module>
    main()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/f2py/f2py2e.py", line 588, in main
    run_compile()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/f2py/f2py2e.py", line 574, in run_compile
    setup(ext_modules = [ext])
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/distutils/core.py", line 186, in setup
    return old_setup(**new_attr)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/distutils/command/build.py", line 37, in run
    old_build.run(self)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run
    self.run_command(cmd_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/distutils/command/build_ext.py", line 232, in run
    self.build_extensions()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 448, in build_extensions
    self.build_extension(ext)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/distutils/command/build_ext.py", line 425, in build_extension
    build_temp=self.build_temp,**kws)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 691, in link_shared_object
    extra_preargs, extra_postargs, build_temp, target_lang)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/distutils/fcompiler/__init__.py", line 643, in link
    libraries)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/distutils/ccompiler.py", line 571, in gen_lib_options
    runtime_library_dirs, libraries)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 1086, in gen_lib_options
    lib_file = compiler.find_library_file([lib_dir], lib_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/ccompiler.py", line 777, in find_library_file
    raise NotImplementedError

So, it looks like I am getting the error from the file ccompiler.py from within the python library.

The error corresponds to the following lines of code in the file:

def find_library_file (self, dirs, lib, debug=0):
        """Search the specified list of directories for a static or shared
        library file 'lib' and return the full path to that file.  If
        'debug' true, look for a debugging version (if that makes sense on
        the current platform).  Return None if 'lib' wasn't found in any of
        the specified directories.
        """
        raise NotImplementedError

I am a little confused about what I need to do to solve this problem as I am new to Python. It seems as if this method has not been implemented yet. Do I just need to implement it? How exactly do I implement this? Would I need to rebuild the f2py executable on making this change? If so, how would I do this?

Thanks!

No correct solution

OTHER TIPS

The question is not answered here, but it does illuminate a workaround (just reference all the *.o files directly instead of putting them in a library). And also, it's just a really great post for explaining some things about f2py.

Including a compiled module in module that is wrapped with f2py (Minimum working example)?

f2py -c --fcompiler=gfortran -I. libtest.o -m Main main.f90

That will work if you library is based on a single file. If your library is (more likely) based on multiple files, just include the full set of *.o names.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top