Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Wednesday, February 6, 2013

F2PY on 64bit Windows (python2.7)

I am writing this post because after hours of frustration I want to share the solution that I found to get F2PY running on a 64 bit windows machine. Ok, here is how it worked out for me,...

If you have old python stuff on your computer, than entirely remove it and download and install components in the following order:

.) Python 2.7.3 Windows X86-64 Installer under http://www.python.org/getit/
.) numpy-unoptimized-1.6.2.win-amd64-py2.7.‌exe under http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy

Then download and extract
.) mingw-w64 under http://sourceforge.net/projects/mingw-w64/
From the extracted directories copy mingw to your c:\mingw

After that, go to your environment variables (under System) and add
.) C:\Python27\Scripts
.) C:\mingw\bin 
to the PATH variable

Add also .py to the PATHEXT variable.


To use F2PY now write: 

f2py -c --fcompiler=gnu95 --compiler=mingw32 -m yourmodulename yourfortranfile

Important note:
I still got an error on my system saying:

"File "C:\Python26\lib\site-packages\numpy\distutils\fcompiler\gnu.py", line 331, in get_libraries raise NotImplementedError("Only MS compiler supported with gfortran on win64") NotImplementedError: Only MS compiler supported with gfortran on win64"

I solved the problem absolutely randomly: 
I changed C:\Python27\Lib\site-packages\numpy\distutils\fcompiler\gnu.py line 331 to:

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

Basically I un commented the NotImplementedError and it worked fine!! GEZUZ!!