Python for .NET:嵌入时 System.BadImageFormatException

DfM*_*DfM 5 .net python embed python.net

我正在尝试将 Python 嵌入到我的 .NET 应用程序中。

我在 Windows 10 上使用 Python 3.6.1 64 位,并且我已经使用 pip 从 PyPi 安装了 pythonnet 2.3.0。

我引用Python.Runtime.dll来自C:\Program Files\Python36\Lib\site-packages和既有PathPYTHONHOME环境变量指向C:\Program Files\Python36\

当我在 Python 中使用 .NET 时一切正常。

import clr
from System.Drawing import Point
p = Point(5, 5)
print(p)
Run Code Online (Sandbox Code Playgroud)

{X=5,Y=5}按预期打印。

但是当我从 .NET 调用 Python 时,我得到System.BadImageFormatException. 例如,调用时Python.Runtime.PythonEngine.Initialize();

System.BadImageFormatException: '无法加载文件或程序集 'Python.Runtime, Version=2.3.0.0, Culture=neutral, PublicKeyToken=null' 或其依赖项之一。试图加载格式不正确的程序。

有什么想法吗?

提前致谢。

DfM*_*DfM 6

正如 denfromufa 所说,我只是从 32 位 .NET 进程调用。