i used pythonnet_netstandard_py37_win 2.5.2 to run numpy method of optimization in .net core3.1, it works properly when i ran in visual studio 2019 in (iis express, any cpu, debug) but when on publish it on iis (on my machie) it gives me error :
`System.TypeInitializationException: The type initializer for 'Delegates' threw an exception.
System.DllNotFoundException: Could not load python311.dll.
System.ComponentModel.Win32Exception (126): The specified module could not be found.
also set enviroment in enviroment variable of windows has been done(regarding to works in debug mode),
searching many issues didnt give me good answer, this line is belong to my code:
Environment.SetEnvironmentVariable("PYTHONNET_PYDLL", "C:/Users/AppData/Local/Programs/Python/python311.dll", EnvironmentVariableTarget.Process);
Runtime.PythonDLL = "python311.dll";
PythonEngine.Initialize();
using (Py.GIL())
{ ....
could someone help me???
2
Answers
This line:
overwrites effect of this line completely:
So Python.NET knows you want python311.dll, but has no idea where to find it.
The error message you are encountering indicates that there is a problem loading the python311.dll library when your application is published on IIS.
You need to ensure that the user account running the IIS application pool has the necessary permissions to access the Python DLL and its folder.
Also, check that your IIS application pool is using the correct bitness (32-bit or 64-bit). If your Python installation and PythonNet are 64-bit, make sure your IIS application pool is configured for 64-bit execution.