✅ 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
As it says, file / module cannot be found
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
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•9mo ago
Message Not Public
Sign In & Join Server To View