0

我按照他们的说明为 IronPython安装了 Enthought 的NumPy 实现。

一切似乎都有效,包括import numpyand import scipy,但是在 IronPython 程序中使用这些语句会导致以下异常:

A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in IronPython.dll

A first chance exception of type 'System.MissingMemberException' occurred in Microsoft.Dynamic.dll

A first chance exception of type 'System.MissingMemberException' occurred in IronPython.dll

A first chance exception of type 'IronPython.Runtime.Exceptions.TypeErrorException' occurred in Snippets.debug.scripting

如何解决这些异常?

4

1 回答 1

0

我不会担心它们,而且我怀疑它们无论如何都可以被删除。这些都映射到 Python 异常,这意味着它们可能是保持与 CPython 的兼容性所必需的。在 CPython 中,异常速度很快(比 .NET 快几个数量级),因此它们在 Python 代码中比在 C# 中更常用。

IronPython 通常使用 .NET 异常机制来显示 Python 异常,这可能会导致某些代码的速度大幅下降。2.7 添加了一个“轻量级异常”机制,但它并没有被一致使用(兼容性现在比性能更重要,但我强烈考虑拉取请求)。可能会修改一些引发这些异常的代码以使用轻量级异常。

于 2012-04-06T15:33:39.713 回答