.NET interop access to Python ecosystem when using Windows
$ dotnet add package DotPythonA .NET library that provides an optimized bridge between .NET and Python through the C++/CLI interop and the CPython API.
using (var pyContext = new PyContext())
{
var np = pyContext.Import("numpy");
var arr = np.array(new[] {0, 1, 2}, dtype: np.int32);
var mean = arr.mean();
}
DotPython will attempt to locate your Python installation in the system's PATH enviroment variable. If you need to specify a custom Python installation, set the Python DLL in the initialization:
Python.Initialize(@"C:\Python312\Python312.dll");