Search code examples
pythonmakefilef2py

make: f2py: No such file or directory


I am running Mac OS X 10.10. I have some python code I have inherited. I need to run "make" in a certain directory, because I get a warning when I run my python script along the lines of WARNING: failed to import test1lib. Please run make in /this/directory/ So I go to that directory where I find the following files:

 Makefile   __init__.py __init__.pyc    foo.py  foo.pyc foo_code.f  foolib.f

So I run $ make

but I get the following error:

f2py -c foolib.f -m foolib
make: f2py: No such file or directory
make: *** [foolib.so] Error 1

Running which f2py returns /usr/local/bin/f2py so its not like I don't have f2py, but why is my terminal expecting f2py to be a directory? What can I do so that I can run make on this case?


Solution

  • If you have f2py, then it's either not on the search PATH, or it has not been made executable.

    I don't know if you are on Linux or Windows. Try to execute f2py manually and see if it starts. If not, try to locate it, and see where it is installed.

    If you can start it from the command line, then show us the Makefile around where the command f2py is located.

    EDIT: Ok... I'm suspecting that f2py is actually a Python script, and it has a shebang line (first line starts with #!) which calls for a python version you don't have. In my system, f2py start with:

    #!/usr/bin/python
    

    which calls python2.7.x... If you have python3, then f2py may not find it. Do you start Python with the python3 command?

    Note: It seems like f2py doesn't come for Python3 ('f2py3' or so).

    Note: The error message you mention can come from a wrong shebang line at the start of f2py (the shebang is the first line of the f2py executable - which is just a Python script). Normally it is

    #!/usr/bin/python
    

    or maybe

    #!/usr/local/bin/python 
    

    if you compiled Python yourself. If it's neither of these, start suspecting. Maybe f2py was installed by some confused tutorial or demo.