2

I am trying to use pythonnet to run a python script from a .Net application , i installed pip , python and the project on git hub , also i did all the installation steps mentioned on https://github.com/pythonnet/pythonnet/wiki/Installation and the troubleshooting steps on https://github.com/pythonnet/pythonnet/wiki/Troubleshooting-on-Windows,-Linux,-and-OSX

when i created a windows application to run a python script, the project was built successfully , however when i click the button to execute a python script the application will exit showing the following output :

The program '[30236] WindowsFormsApplication1.vshost.exe: Program Trace' has exited with code 0 (0x0). The program '[30236] WindowsFormsApplication1.vshost.exe' has exited with code 1 (0x1).

the code i am using to execute the python file :

 try
            {
                using (Py.GIL())
                {
                    var test1 = "";

                    dynamic np = Py.Import("sum");
                    Console.WriteLine(np.cos(np.pi * 2));
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

when i tried to check where exactly the project stops , it was in the Python.RunTime project => runtime.cs =? Initialize() .

P.S : i am using pythonnet because i am using python 3.X and IronPython does not support this version.

Is there additional troubleshooting steps i must do ? or any more reference i should add ?

denfromufa
  • 5,610
  • 13
  • 81
  • 138
ibrahim noureddine
  • 99
  • 1
  • 1
  • 11
  • https://github.com/pythonnet/pythonnet/issues/599 – denfromufa Jan 17 '18 at 18:17
  • It was a mismatch between the installed python version on my device and the compilation symbol default values , i set it to match my python version the problem solved, however some warning still exists in the code like "A call to PInvoke function " however the code will not crash because of them.. i still have one more issue about importing the python file , an exception occurs with an unreadable exception message (it is encoded) – ibrahim noureddine Jan 18 '18 at 13:18

0 Answers0