名称错误:名称“f2py”没有定义
安装 python、numpy 和 scipy_dist_utils 后,我在 python 解释器中输入 f2py 结果如下
>>> 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 解决了问题 但这现在不起作用 f2py -c --help-fcompiler
f2py -c --help-fcompiler 回溯(最近一次调用最后一次): 文件“”,第 1 行,位于 f2py -c --帮助-f编译器 NameError:名称“c”未定义
<块引用> <块引用>
出了什么问题?谁能帮我解决这个问题吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您必须输入:
另外,请确保拥有最新版本的 numpy。
You have to type:
Also, be sure to have a recent version of
numpy
.在尝试使用
f2py
之前,您是否输入过from numpy import f2py
?Did you type
from numpy import f2py
before trying to usef2py
?罗伯特·科恩是正确的。您无法从 python 中运行它。我的 Windows 计算机上也出现了类似的错误。问题是 f2py 不在路径中。
您必须在命令提示符下通过以下方法调用 f2py。
这应该允许它被调用。
例如,我在 C 目录的
Python34
文件夹中安装了 python 3.4,在子文件夹Scripts
中安装了 f2py。因此,我对 f2py 的调用是 python C:\Python34\Scripts\f2py.py。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.
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 subfolderScripts
. So, my call to f2py ispython C:\Python34\Scripts\f2py.py
.如果您尝试运行 f2py,请从命令 shell(UNIX 计算机上的 bash 或其他命令,Windows 上的 CMD)执行此操作,而不是从 Python 解释器执行。没有太多可以做的事情
此外,scipy_distutils 非常非常旧,根本不再使用。任何告诉您安装的说明都已经过时了。有关更新的说明集:
http://www.scipy.org/F2py
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