我正在尝试在我的.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
,并且Path
和PYTHONHOME
环境变量都指向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'或其依赖项之一。试图加载格式不正确的程序。
有什么想法吗?
提前致谢。
As denfromufa said,我只是从一个32位的.NET进程调用。