Python for .NET:嵌入时的System.BadImageFormatException

问题描述 投票:3回答:1

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

我在Windows 10上使用64位的Python 3.6.1并且我使用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)

按预期打印{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'或其依赖项之一。试图加载格式不正确的程序。

有什么想法吗?

提前致谢。

python .net embed python.net
1个回答
3
投票

As denfromufa said,我只是从一个32位的.NET进程调用。

© www.soinside.com 2019 - 2024. All rights reserved.