Moritz
Moritz

Reputation: 5418

f2py does not find any compiler

I have the NAG Fortran compiler installed. I can compile Fortran code by calling nagfor -o helloworld helloworld.f90. If I run f2py with f2py -c -m helloworld helloworld.f90 --fcompiler=nagfor nothing happens. Additionally, if I just run f2py nothing happens. f2py --help-fcompiler gives no output.

I have Windows 7 installed and use the the Anaconda Python distribution. Any idea how I should address this problem?

Upvotes: 2

Views: 2293

Answers (2)

Moritz
Moritz

Reputation: 5418

Following Ian`s comments and this post I managed to run f2py (unfortunately only with the GNU Fortran compiler).

I had to change line 337 in C:\Loopy\Lib\site-packages\numpy\distutils\fcompiler\gnu.py to:

pass #raise NotImplementedError("Only MS compiler supported with gfortran on win64")

Additionally I use C:\Loopy\Scripts\f2py.py.

Upvotes: 1

IanH
IanH

Reputation: 10710

It's unusual that you aren't seeing any error output at all. That makes it sound like you're calling something else. Make sure Anaconda's scripts directory on your path and that you don't have some sort of script in your current directory called f2py. Depending on how you have your computer is set up to interpret file types, you may need to run something like python f2py.py with the rest of the arguments the same.

If you're using Anaconda, you should already have a copy of gfortran intsalled too. If you want to use that instead, make sure Anaconda's bin directory is on your path. Unless you have a very recent (1.10, currently in development) version of numpy, to use gfortran, you'll need to go to Anaconda/Lib/site-packages/numpy/distutils/fcompiler/gnu.py and comment out the lines (somewhere around line 330) that raise an error if you're on 64 bit windows. Once you've done that, it should work fine.

Edit: judging by the old f2py docs and the current source, the proper fcompiler flag is --fcompiler=nag. The compiler is specified by vendor, not by executable name.

Upvotes: 0

Related Questions