无法在IronPython中导入scipy,但可以导入numpy

2 投票
1 回答
965 浏览
提问于 2025-04-18 05:54

我正在尝试把我的代码从 Python(v2.7) 移植到 IronPython,这样我就可以利用实验室电脑上的多个核心。

我首先从这个网站安装了 IronPythonhttp://ironpython.net/

然后我按照这里的说明安装了(或者至少我认为我安装了)numpyscipyhttps://www.enthought.com/repo/.iron/
我还尝试了页面上给的最后一个命令(> ipy -X:Frames -c "import scipy"),因为命令提示符没有报错,所以我以为一切都顺利。

但奇怪的是,我可以导入 numpy,却无法导入 scipy。我收到的错误信息如下:

IronPython 2.7.4 (2.7.0.40) on .NET 4.0.30319.18444 (32-bit)
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.pi
3.141592653589793
>>> import scipy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\scipy\__init__.p
y", line 124, in <module>
  File "C:\Program Files (x86)\IronPython 2.7\lib\site-packages\numpy\_import_to
ols.py", line 15, in __init__
AttributeError: 'module' object has no attribute '_getframe'

我在这里漏掉了什么吗?我在谷歌上搜索了 AttributeError: 'module' object has no attribute '_getframe',但没有找到解决我问题的方法。

1 个回答

0

你有没有试过使用交互式窗口?你可以像这样添加“-X:Frames”

1. Go to: Tools -> Options -> Python Tools -> Interactive Windows -> IronPython 2.7

2. Set "Interpreter Options" to "-X:Frames"

另外,运行这个命令时,检查一下输出中是否有“-X:Frames”

PS> ( Get-WmiObject Win32_Process -Filter "Name like '%ipy%'" ).CommandLine

如果没有,那就说明“-X:Frames”出了点问题。

撰写回答