You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have used Python.NET from C# on Windows for years (huge thank you to all). I'm now trying get some stuff running on Linux and .NET8.
Using latest nuget for Python.NET (3.0.5) everything works great under Windows. But on Ubuntu 24.04.2 LTS I get:
Unhandled exception. System.TypeInitializationException: The type initializer for 'Delegates' threw an exception.
---> System.DllNotFoundException: Could not load /usr/lib/x86_64-linux-gnu/libpython3.12.so.1.0 with flags RTLD_NOW | RTLD_GLOBAL: /usr/lib/x86_64-linux-gnu/libpython3.12.so.1.0: cannot open shared object file: No such file or directory
at Python.Runtime.Platform.PosixLoader.Load(String dllToLoad)
at Python.Runtime.Runtime.Delegates.GetUnmanagedDll(String libraryName)
at Python.Runtime.Runtime.Delegates..cctor()
--- End of inner exception stack trace ---
at Python.Runtime.Runtime.Delegates.get_Py_IsInitialized()
at Python.Runtime.Runtime.Py_IsInitialized()
at Python.Runtime.Runtime.<>c.<Initialize>b__32_0()
at Python.Runtime.Runtime.TryUsingDll[T](Func`1 op)
at Python.Runtime.Runtime.Initialize(Boolean initSigs)
at Python.Runtime.PythonEngine.Initialize(IEnumerable`1 args, Boolean setSysArgv, Boolean initSigs)
at Python.Runtime.PythonEngine.Initialize(Boolean setSysArgv, Boolean initSigs)
at Python.Runtime.PythonEngine.Initialize()
Python looks OK?
$ ls -l /usr/lib/x86_64-linux-gnu/libpython3.12.so*
lrwxrwxrwx 1 root root 20 Feb 4 08:48 /usr/lib/x86_64-linux-gnu/libpython3.12.so.1 -> libpython3.12.so.1.0
-rw-r--r-- 1 root root 9055112 Feb 4 08:48 /usr/lib/x86_64-linux-gnu/libpython3.12.so.1.0
Code:
using Python.Runtime;
Console.WriteLine("Starting up ...");
Runtime.PythonDLL = "/usr/lib/x86_64-linux-gnu/libpython3.12.so.1.0";
//Runtime.PythonDLL = @"C:\Skyworks\Git\Tools3\Misc\MiniPythonDistis\PythonForCBPro312\python312.dll";
Console.WriteLine("Initializing Python.NET ...");
PythonEngine.Initialize();
Console.WriteLine("Done");
using (Py.GIL())
{
dynamic hello = Py.Import("hello");
hello.say_hello();
}
I have used Python.NET from C# on Windows for years (huge thank you to all). I'm now trying get some stuff running on Linux and .NET8.
Using latest nuget for Python.NET (3.0.5) everything works great under Windows. But on Ubuntu 24.04.2 LTS I get:
Python looks OK?
Code:
Full C# project:
PythonDotNetDotNET8Sample.zip
Any tips? Thank you.
The text was updated successfully, but these errors were encountered: