2

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?

Dipole
  • 1,840
  • 2
  • 24
  • 35

1 Answers1

2

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.

jcoppens
  • 5,306
  • 6
  • 27
  • 47
  • Thanks. Do you mean just typing `f2py` in the terminal? If so I get `-bash: /usr/local/bin/f2py: /Users/travis/build/MacPython/numpy-wheels/venv/bin/python: bad interpreter: No such file or directory` Im running OS X btw – Dipole May 25 '15 at 14:13
  • I edited the reply above... f2py does not seem to come for Python3. Here's a link to more discussion on the subject: http://stackoverflow.com/questions/30000857/install-f2py-with-python3 – jcoppens May 25 '15 at 14:22
  • Just typing 'python' start python? Try `python -V` that should print the version – jcoppens May 25 '15 at 14:24
  • Yes, it is python 2.7.6 – Dipole May 25 '15 at 14:25
  • Indeed you are correct about the shebang line- in mine it is set to /Users/travis/build/MacPython/numpy-wheels/venv/bin/python which I don't understand. Should it be changed to /usr/bin/python? – Dipole May 25 '15 at 14:30
  • When I do this it seems to work! Why on earth would my shebang line have been changed from the default? I certainly have not changed it! Could you also explain how you drew the conclusion that the shebang line was calling for a version of python that I don't have? Im trying to learn about these things so that I can become better at solving these issues in the future! Happy to accept your answer – Dipole May 25 '15 at 14:36
  • Well, with the /usr/bin shebang you are using the system's Python, while with the large one, you try to call a Python in a virtual environment in you own directory. Which may (or may not) be the same version (and may not exist anymore). Try (from a terminal) calling `/Users/travis/build/MacPython/numpy-wheels/venv/bin/python -V` (by the way - that probably comes from a tutorial for numpy) – jcoppens May 25 '15 at 14:41