Calling Fortran from Python

Robert Kern robert.kern at gmail.com
Wed Apr 4 19:22:15 CEST 2007


Mangabasi wrote:
> Robert,
> 
> Thanks for your prompt response.  I think I got a lot closer but no
> cigar yet.
> 
> This is the output
> 
> C:\fortrandll>f2py -c -m sample sample.pyf sample.for
> numpy_info:
>   FOUND:
>     define_macros = [('NUMERIC_VERSION', '"\\"24.2\\""')]
>     include_dirs = ['C:\\Python24\\include']
> 
> running build
> running config_fc
> running build_src
> building extension "sample" sources
> creating c:\docume~1\fb\locals~1\temp\tmpcosvgv
> creating c:\docume~1\fb\locals~1\temp\tmpcosvgv\src
> f2py: sample.pyf
> Reading fortran codes...
>         Reading file 'sample.pyf'
> Post-processing...
>         Block: sample
>                         Block: sample
> Post-processing (stage 2)...
> Building modules...
>         Building module "sample"...
>                 Constructing wrapper function "sample"...
>                   ierr1,ierr2,aout = sample(ain)
>         Wrote C/API module "sample" to file "c:\docume~1\fb
> \locals~1\temp\tmpcos
> vgv\src/samplemodule.c"
>   adding 'c:\docume~1\fb\locals~1\temp\tmpcosvgv\src\fortranobject.c'
> to sources
> .
>   adding 'c:\docume~1\fb\locals~1\temp\tmpcosvgv\src' to include_dirs.
> copying C:\python24\lib\site-packages\f2py2e\src\fortranobject.c -> c:
> \docume~1\
> fb\locals~1\temp\tmpcosvgv\src
> copying C:\python24\lib\site-packages\f2py2e\src\fortranobject.h -> c:
> \docume~1\
> fb\locals~1\temp\tmpcosvgv\src
> running build_ext
> No module named msvccompiler in scipy_distutils, trying from
> distutils..
> error: The .NET Framework SDK needs to be installed before building
> extensions f
> or Python.
> 
> I think I have a problem with distutils' msvccompiler.py.  It may be
> the MacroExpander in distutils guessing the visual studio path
> incorrectly or something related to the registry keys.  Is there a way
> to specify the C compiler path to f2py so that it does not rely on the
> distutils?  Or maybe I am totally off base here, I don't know.

What C and Fortran compilers are you trying to use? You can look at f2py's help
for flags that you can use to help control where the compilers get picked up,
but you can't avoid distutils.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the Python-list mailing list