First time here? Check out the FAQ!

Ask Your Question
1

how to use sage's f2py from linux command line?

asked 12 years ago

juanpool gravatar image

updated 12 years ago

I usually run python scripts using SAGE via the command,

sage -python program.py

Now I want to use f2py to use a FORTRAN subroutine in my program. In my Linux version (Ubuntu 12.04) I have installed f2py (version 2), but that version does not use SAGE's Python as I can see from the following. I have a FORTRAN code in rw2.f90 and I run in a linux console,

$f2py -m -c rw2 rw2.f90

and it throws the following message,

error: Command "gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/tmp/tmpyFNYE_/src.linux-x86_64-2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c /tmp/tmpyFNYE_/src.linux-x86_64-2.7/fortranobject.c -o /tmp/tmpyFNYE_/tmp/tmpyFNYE_/src.linux-x86_64-2.7/fortranobject.o" failed with exit status 1

From the message, it is clear that f2py is trying to use the version of Python that comes with my ubuntu. But I want that f2py to use the SAGE's Python. How I do that?

Best regards

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 12 years ago

Mike Hansen gravatar image

Try running

$ sage -sh

from the command-line first. When you then run,

$ f2py -m -c rw2 rw2.f90

it will pick up Sage's copy of f2py (which will use Sage's Python).

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 12 years ago

Seen: 597 times

Last updated: May 18 '12