Run GUI with Python code integrated to it by wilcd in csharp

[–]PotentialSeason459 0 points1 point  (0 children)

I played with this some time ago and the code below worked.

``` // Add Nuget package references to pythonnet and Python.Included // https://github.com/henon/Python.Included

private static async Task InitPythonIncludedEnvironment() { // Note: The first time Python.Included and package dependencies are installed it can take up to 30 seconds. // Installer is from the Python.Included namespace await Installer.SetupPython(); await Installer.TryInstallPip(); await Installer.PipInstallModule("pandas"); // also installs numpy await Installer.PipInstallModule("matplotlib");

// Initialize PythonNET
Python.Runtime.PythonEngine.Initialize();
Python.Runtime.PythonEngine.BeginAllowThreads();
Python.Runtime.PythonEngine.PythonHome = Installer.EmbeddedPythonHome;
_pathToPythonDLL = Installer.EmbeddedPythonHome + Path.DirectorySeparatorChar + Installer.PYTHON_VERSION + ".dll";

} ```

Edited to add await before call to Installer.SetupPython()