I am interested to call my existing python 3.8 modules from an developed WPF Application(Net Core3.1). I did the following:
- I installed pythonnet with: pip install pythonnet
- Set environment paths in C# (in VS2019) :
string pyInstallDir = @"C:\Python38"; Environment.SetEnvironmentVariable("PATH", pyInstallDir, EnvironmentVariableTarget.Process); Environment.SetEnvironmentVariable("PYTHONHOME", pyInstallDir, EnvironmentVariableTarget.Process); Environment.SetEnvironmentVariable("PYTHONPATH", Path.Combine(pyInstallDir, @"Lib\site-packages"), EnvironmentVariableTarget.Process); Environment.SetEnvironmentVariable("PYTHONNET_PYDLL", pyInstallDir, EnvironmentVariableTarget.Process);
Referenced the Python.Runtime.dll from the "C:\Python38\Lib\site-packages" folder in my project and added using Python.Runtime;
Tried to import numpy(as Demo)
using (Py.GIL()) { dynamic np = Py.Import("numpy"); }
I get the following error:
Can anyone help to fix the error??
I have several approaches from the forums but without success.