[Python.NET] how to use an embedded python intepreter?

Serge WEINSTOCK serge.weinstock at uk.bnpparibas.com
Wed Aug 13 15:35:30 CEST 2014


I'm trying to use an embedded python interpreter from C# using pythonnet (the python3 compatible version found at https://github.com/renshawbay/pythonnet)

My interpreter is located in D:\src\scratch\TestPythonNet\TestPythonNet\PythonRuntime and has the "Lib" and "Libs" folder from the python distribution.

I've tested using the following code:

//====================================================================

PythonEngine.PythonHome = @"D:\src\scratch\TestPythonNet\TestPythonNet\PythonRuntime";

PythonEngine.ProgramName = "PythonRuntime";

PythonEngine.Initialize();

using (Py.GIL())

{

    PythonEngine.RunSimpleString("print(1)");

}

//====================================================================

But, it doesn't work. I get a "SystemError: PyEvalCodeEx: NULL globals". Everytime I try to get an object from python, the code fails.

What am I doing wrong?


___________________________________________________________
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is prohibited.

Please refer to http://www.bnpparibas.co.uk/en/email-disclaimer/ for additional disclosures.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20140813/d733dab6/attachment.html>


More information about the PythonDotNet mailing list