I am having a weird error trying to use .NET dll in a python program.
C:\temp>"c:\apps\WPy64-37120\pypy3.7-v7.3.7-win64\python.exe" example.py
Failed to initialize pythonnet: System.TypeInitializationException: The type initializer for 'Delegates' threw an exception. ---> Python.Runtime.BadPythonDllException: Runtime.PythonDLL was not set or does not point to a supported Python runtime DLL. See https://github.com/pythonnet/pythonnet#embedding-python-in-net ---> System.MissingMethodException: Failed to load symbol Py_IncRef. ---> System.ComponentModel.Win32Exception: The specified procedure could not be found
--- End of inner exception stack trace --- at Python.Runtime.Platform.WindowsLoader.GetFunction(IntPtr hModule, String procedureName) at Python.Runtime.Runtime.Delegates.GetFunctionByName(String functionName, IntPtr libraryHandle) --- End of inner exception stack trace --- at Python.Runtime.Runtime.Delegates.GetFunctionByName(String functionName, IntPtr libraryHandle) at Python.Runtime.Runtime.Delegates..cctor() --- End of inner exception stack trace --- at Python.Runtime.Runtime.Delegates.get_PyGILState_Ensure() at Python.Runtime.Runtime.PyGILState_Ensure() at Python.Runtime.Loader.Initialize(IntPtr data, Int32 size) at Python.Runtime.Runtime.Delegates.get_PyGILState_Ensure() at Python.Runtime.Runtime.PyGILState_Ensure() at Python.Runtime.Loader.Initialize(IntPtr data, Int32 size)Traceback (most recent call last): File "example.py", line 2, in from SimpleAxisFile import SimpleAxisFile File "c:\apps\WPy64-37120\pypy3.7-v7.3.7-win64\site-packages\SimpleAxisFile_init_.py", line 16, in import clr File "c:\apps\WPy64-37120\pypy3.7-v7.3.7-win64\site-packages\clr.py", line 6, in load() File "c:\apps\WPy64-37120\pypy3.7-v7.3.7-win64\site-packages\pythonnet_init_.py", line 44, in load raise RuntimeError("Failed to initialize Python.Runtime.dll") RuntimeError: Failed to initialize Python.Runtime.dll
The same code used to work with WinPython 3.7 before.
I do have PYTHONNET_PYDLL environment variable set to "C:\apps\WPy64-37120\pypy3.7-v7.3.7-win64\site-packages\pythonnet\runtime\Python.Runtime.dll"
Any ideas why it is not working?
Thank you.