Python引擎。初始化()失败,没有任何错误消息

2024-09-30 12:26:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图将Python嵌入到C应用程序中,但似乎无法使其正常工作。 我的代码是

using System;
using Python.Runtime;

namespace NLP.Python
{
   public class PythonRumtime
   {
       public PythonRuntime()
    {
       //Location of python installation
       PythonEngine.PythonHome = "C:\\Python27";
       PythonEngine.Initialize();
     }
    }
 }

当我试图创建这个类的实例时,代码在调用时没有任何错误Python引擎。初始化() 我已经添加了一个dll引用Python.运行时是用Python装的。在

我不知道还能做什么。在

我已经通过pip在一台安装了pythonnet 2.7.11的32位windows64位机器上安装了pythonnet-2.1.0。在

编辑错误似乎发生在调用中的Py_Initialize()时Python.Runtime.dll. 根据https://docs.python.org/2/c-api/init.html“没有返回值;如果初始化失败,这是一个致命错误。”


Tags: 代码应用程序nlp错误publicnamespacesystemclass

热门问题