Skip to main content
 首页 » 编程设计

python之名称错误 : name 'f2py' is not defined

2025年05月04日11cmt

安装 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 --help-fcompiler NameError: 名称 'c' 未定义

出了什么问题?谁能帮我解决这个问题?

请您参考如下方法:

如果您尝试运行 f2py,您可以从命令 shell(bash 或 UNIX 机器上的任何东西,Windows 上的 CMD)执行,而不是从 Python 解释器执行。您无能为力

此外,scipy_distutils 非常非常旧,根本不再使用。任何告诉您安装的说明都已经过时了。有关更新的说明集:

http://www.scipy.org/F2py