C
C#8mo ago
banshi

✅ Python.Net import issue

I'm trying to execute my python script from .Net using pythonnet package & i'm doing this in my wsl Ubuntu machine but when i try to import my script it throwing an error Unhandled exception. Python.Runtime.PythonException: No module named 'myScript' using Python.Runtime; ExecuteScriptUsingPythonNet("myScript"); static void ExecuteScriptUsingPythonNet(string scriptName) { Runtime.PythonDLL = @"/usr/lib/x86_64-linux-gnu/libpython3.10.so"; PythonEngine.Initialize(); using (Py.GIL()) { dynamic pythonScript = Py.Import(scriptName); dynamic result = pythonScript.add_numbers(3, 5); // dynamic result = pythonScript.getImage(); Console.WriteLine("Result: " + result); } PythonEngine.Shutdown(); }
4 Replies
Buddy
Buddy8mo ago
As it says, file / module cannot be found
banshi
banshiOP8mo ago
yeah but my script file is there in same directory where program.cs is the same code is working in windows with same file structure
Buddy
Buddy8mo ago
Yeah, no. That's not the working directory The working directory is in bin/debug/ or bin/release/ -- depending on the release mode, and configuration.
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server