sunil bhandari
sunil bhandari

Reputation: 11

NameError: name 'f2py' is not defined

after installing python, numpy and scipy_dist_utils i typed f2py onto the python interpretor the result is as below

>>> f2py
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    f2py
NameError: name 'f2py' is not defined
>>> import numpy
>>> f2py
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    f2py
NameError: name 'f2py' is not defined

from numpy import f2py solved the problem but this does not work now f2py -c --help-fcompiler

f2py -c --help-fcompiler Traceback (most recent call last): File "", line 1, in f2py -c --help-fcompiler NameError: name 'c' is not defined

What has gone wrong? could anyone help me with this?

Upvotes: 1

Views: 2937

Answers (4)

jknicely
jknicely

Reputation: 357

Robert Kern is correct. You cannot run it from within python. I had a similar error on my windows computer. The problem is that f2py is not in the path.

You'll have to call f2py in the following method from the command prompt.

python C:\Path\to\f2py.py

That should allow it to be called.

As an example, I have python 3.4 installed in the C directory in the folder Python34 with f2py in the subfolder Scripts. So, my call to f2py is python C:\Python34\Scripts\f2py.py.

Upvotes: 0

Robert Kern
Robert Kern

Reputation: 13430

If you are trying to run f2py, you do that from your command shell (bash or whatever on UNIX machines, CMD on Windows), not from the Python interpreter. There isn't a whole lot you can do with

Also, scipy_distutils is very, very old and not at all used anymore. Whatever instructions that told you to install that are incredibly out of date. For a somewhat more up to date set of instructions:

http://www.scipy.org/F2py

Upvotes: 4

Paul
Paul

Reputation: 43620

Did you type from numpy import f2py before trying to use f2py?

Upvotes: 2

Andrea Spadaccini
Andrea Spadaccini

Reputation: 12651

You have to type:

import numpy.f2py

Also, be sure to have a recent version of numpy.

Upvotes: 2

Related Questions