Repository: IronLanguages/ironpython3

Issue #1811: Switching project from .net 8 to 9 will cause input function to throw ArgumentException
Created: 2024-11-16T02:06:40Z
Prerequisites
.net 8 and .net 9 application with embedded IronPython3
The issue tracker is used to report bugs and request new features, NOT to ask questions.
Questions should be posted in Discussions or to the users mailing list which can be accessed at
https://ironpython.groups.io/g/users.

 Are you running the latest version?
 Are you reporting to the correct repository?
 Did you perform a cursory search?

Description
I have an application with embedded IronPython. When I build it with .net 8 it works fine. However, if I build it with .net 9 the input() function will throw an exception:
System.ArgumentException: Type doesn't have a method with a given name and signature. (Parameter 'type')
Here is the call stack:
at Microsoft.Scripting.Utils.ContractUtils.Requires(Boolean precondition, String paramName, String message)
at Microsoft.Scripting.Generation.ILGen.EmitCall(Type type, String name, Type[] paramTypes)
at IronPython.Runtime.Types.NewTypeMaker.ImplementCTDOverride(MethodInfo m)
at IronPython.Runtime.Types.NewTypeMaker.ImplementCustomTypeDescriptor()
at IronPython.Runtime.Types.NewTypeMaker.ImplementPythonObject()
at IronPython.Runtime.Types.NewTypeMaker.ImplementType()
at IronPython.Runtime.Types.NewTypeMaker.CreateNewType()
at IronPython.Runtime.Types.NewTypeMaker.<>c__DisplayClass24_0.b__0()
at Microsoft.Scripting.Utils.Publisher2.GetOrCreateValue(TKey key, Func1 create)
at IronPython.Runtime.Types.NewTypeMaker.GetNewType(String typeName, PythonTuple bases)
at IronPython.Runtime.Types.PythonType.InitializeUserType(CodeContext context, String name, PythonTuple bases, PythonDictionary vars, String selfNames)
at IronPython.Runtime.Types.PythonType..ctor(CodeContext context, String name, PythonTuple bases, PythonDictionary dict, String selfNames)
at IronPython.Runtime.Types.PythonType.new(CodeContext context, PythonType cls, String name, PythonTuple bases, PythonDictionary dict, String selfNames)
at IronPython.Runtime.Operations.PythonOps.MakeClass(FunctionCode funcCode, Func2 body, CodeContext parentContext, String name, PythonTuple bases, PythonDictionary keywords, String selfNames) at Microsoft.Scripting.Interpreter.FuncCallInstruction8.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at IronPython.Compiler.PythonScriptCode.Run(Scope scope)
at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope)
at IronPython.Runtime.ZipImportModule.zipimporter.load_module(CodeContext context, String fullname)
at Microsoft.Scripting.Interpreter.FuncCallInstruction4.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3) at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) in /_/src/libraries/System.Linq.Expressions/src/System/Dynamic/UpdateDelegates.Generated.cs:line 376 at Microsoft.Scripting.Interpreter.FuncCallInstruction6.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at IronPython.Runtime.PythonContext.Call(CodeContext context, Object func, Object arg0)
at IronPython.Runtime.Importer.FindAndLoadModuleFromImporter(CodeContext context, Object importer, String fullName, PythonList path, Object& ret)
at IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, PythonList path, Func5 defaultLoader) at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, PythonList path) at IronPython.Runtime.Importer.ImportTopAbsolute(CodeContext context, String name) at IronPython.Runtime.Importer.ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level) at IronPython.Modules.Builtin.__import__(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level) at Microsoft.Scripting.Interpreter.FuncCallInstruction7.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
at IronPython.Runtime.Importer.ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level)
at IronPython.Runtime.Operations.PythonOps.ImportTop(CodeContext context, String fullName, Int32 level)
at Microsoft.Scripting.Interpreter.FuncCallInstruction4.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1) at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx) at IronPython.Compiler.PythonScriptCode.Run(Scope scope) at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope) at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope) at IronPython.Runtime.ZipImportModule.zipimporter.load_module(CodeContext context, String fullname) at Microsoft.Scripting.Interpreter.FuncCallInstruction4.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) in //src/libraries/System.Linq.Expressions/src/System/Dynamic/UpdateDelegates.Generated.cs:line 418
at Microsoft.Scripting.Interpreter.FuncCallInstruction6.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3) at IronPython.Runtime.PythonContext.Call(CodeContext context, Object func, Object arg0) at IronPython.Runtime.Importer.FindAndLoadModuleFromImporter(CodeContext context, Object importer, String fullName, PythonList path, Object& ret) at IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, PythonList path, Func5 defaultLoader)
at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, PythonList path)
at IronPython.Runtime.Importer.ImportTopAbsolute(CodeContext context, String name)
at IronPython.Runtime.Importer.ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level)
at IronPython.Runtime.PythonContext.EnsureEncodings()
at IronPython.Runtime.Operations.PythonOps.LookupEncoding(CodeContext context, String encoding)
at IronPython.Modules.PythonIOModule.TextIOWrapper.GetDecoder(CodeContext context)
at IronPython.Modules.PythonIOModule.TextIOWrapper.readline(CodeContext context, Int32 limit)
at Microsoft.Scripting.Interpreter.FuncCallInstruction4.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3) at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) in /_/src/libraries/System.Linq.Expressions/src/System/Dynamic/UpdateDelegates.Generated.cs:line 418 at IronPython.Runtime.PythonContext.CallSplat(CodeContext context, Object func, Object[] args) at IronPython.Runtime.Operations.PythonCalls.Call(CodeContext context, Object func, Object[] args) at IronPython.Runtime.Operations.PythonOps.Invoke(CodeContext context, Object target, String name, Object[] args) at IronPython.Runtime.Operations.PythonOps.ReadLine(CodeContext context, Object f) at IronPython.Runtime.Operations.PythonOps.ReadLineFromSrc(CodeContext context, Object src) at IronPython.Modules.Builtin.input(CodeContext context, Object prompt) at Microsoft.Scripting.Interpreter.FuncCallInstruction3.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) in //src/libraries/System.Linq.Expressions/src/System/Dynamic/UpdateDelegates.Generated.cs:line 418
at Microsoft.Scripting.Interpreter.DynamicInstruction`4.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at IronPython.Compiler.PythonScriptCode.Run(Scope scope)
at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope)
at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink)
at Microsoft.Scripting.SourceUnit.Execute(Scope scope)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at Microsoft.Scripting.Hosting.ScriptEngine.Execute(String expression, ScriptScope scope)
at LogicCircuit.IronPythonConsole.<>c__DisplayClass26_0.g__run|0() in C:\Projects\LogicCircuit\LogicCircuit\master\Sources\LogicCircuit\Dialog\IronPythonConsole.xaml.cs:line 166
[Description of the bug or feature]
Steps to Reproduce
I've actually build a small project to repro this. please see the attached.

Build the provided solution
with default .net 8 it should work.
Change TargetFramework to .net 9
Rebuild and run.

Expected behavior:
[What you expected to happen]
Expecting the program to work without exceptions.
Actual behavior:
throws

.NET platform used (choice from: .NET, .NET Core, .NET Framework, Mono, Unity, Xamarin),
Version of the .NET platform used,
Operating system used: win 10
Value of sys.version, from imported module sys.

IronPythonErrorTest.zip

Duplicate issue #1831: can not work on .net9.0
Created: 2024-12-06T03:36:13Z
as below ipy code, when I run it on .net9.0, throw a  exception:
Error:
at Microsoft.Scripting.Utils.Publisher2.GetOrCreateValue(TKey key, Func1 create)
at IronPython.Runtime.Types.NewTypeMaker.GetNewType(String typeName, PythonTuple bases)
at IronPython.Runtime.Types.PythonType.InitializeUserType(CodeContext context, String name, PythonTuple bases, PythonDictionary vars, String selfNames)
at IronPython.Runtime.Types.PythonType..ctor(CodeContext context, String name, PythonTuple bases, PythonDictionary dict, String selfNames)
at IronPython.Runtime.Types.PythonType.new(CodeContext context, PythonType cls, String name, PythonTuple bases, PythonDictionary dict, String selfNames)
at IronPython.Runtime.Operations.PythonOps.MakeClass(FunctionCode funcCode, Func2 body, CodeContext parentContext, String name, PythonTuple bases, PythonDictionary keywords, String selfNames) at Microsoft.Scripting.Interpreter.FuncCallInstruction8.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope)
at IronPython.Runtime.PythonContext.InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options)
at IronPython.Runtime.PythonContext.CompileModule(String fileName, String moduleName, SourceUnit sourceCode, ModuleOptions options, ScriptCode& scriptCode)
at IronPython.Runtime.PythonContext.CompileModule(String fileName, String moduleName, SourceUnit sourceCode, ModuleOptions options)
at IronPython.Runtime.Importer.LoadFromSourceUnit(CodeContext context, SourceUnit sourceCode, String name, String path)
at IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext context, String name, String path)
at IronPython.Runtime.Importer.LoadFromDisk(CodeContext context, String name, String fullName, String str)
at IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, PythonList path, Func5 defaultLoader) at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, PythonList path) at IronPython.Runtime.Importer.ImportTopAbsolute(CodeContext context, String name) at IronPython.Runtime.Importer.ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level) at IronPython.Modules.Builtin.__import__(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level) at Microsoft.Scripting.Interpreter.FuncCallInstruction7.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
at IronPython.Runtime.Importer.ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level)
at IronPython.Runtime.Operations.PythonOps.ImportWithNames(CodeContext context, String fullName, String[] names, Int32 level)
at Microsoft.Scripting.Interpreter.FuncCallInstruction5.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0) at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope) at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope) at IronPython.Runtime.PythonContext.InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options) at IronPython.Runtime.PythonContext.CompileModule(String fileName, String moduleName, SourceUnit sourceCode, ModuleOptions options, ScriptCode& scriptCode) at IronPython.Runtime.PythonContext.CompileModule(String fileName, String moduleName, SourceUnit sourceCode, ModuleOptions options) at IronPython.Runtime.Importer.LoadFromSourceUnit(CodeContext context, SourceUnit sourceCode, String name, String path) at IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext context, String name, String path) at IronPython.Runtime.Importer.LoadFromDisk(CodeContext context, String name, String fullName, String str) at IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, PythonList path, Func5 defaultLoader)
at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, PythonList path)
at IronPython.Runtime.Importer.ImportTopAbsolute(CodeContext context, String name)
at IronPython.Runtime.Importer.ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level)
at IronPython.Modules.Builtin.import(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level)
at Microsoft.Scripting.Interpreter.FuncCallInstruction7.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) at IronPython.Runtime.Importer.ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level) at IronPython.Runtime.Operations.PythonOps.ImportWithNames(CodeContext context, String fullName, String[] names, Int32 level) at Microsoft.Scripting.Interpreter.FuncCallInstruction5.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope)
at IronPython.Runtime.PythonContext.InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options)
at IronPython.Runtime.PythonContext.CompileModule(String fileName, String moduleName, SourceUnit sourceCode, ModuleOptions options, ScriptCode& scriptCode)
at IronPython.Runtime.PythonContext.CompileModule(String fileName, String moduleName, SourceUnit sourceCode, ModuleOptions options)
at IronPython.Runtime.Importer.LoadFromSourceUnit(CodeContext context, SourceUnit sourceCode, String name, String path)
at IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext context, String name, String path)
at IronPython.Runtime.Importer.LoadFromDisk(CodeContext context, String name, String fullName, String str)
at IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, PythonList path, Func5 defaultLoader) at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, PythonList path) at IronPython.Runtime.Importer.ImportTopAbsolute(CodeContext context, String name) at IronPython.Runtime.Importer.ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level) at IronPython.Modules.Builtin.__import__(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level) at Microsoft.Scripting.Interpreter.FuncCallInstruction7.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
at IronPython.Runtime.Importer.ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level)
at IronPython.Runtime.Operations.PythonOps.ImportWithNames(CodeContext context, String fullName, String[] names, Int32 level)
at Microsoft.Scripting.Interpreter.FuncCallInstruction5.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0) at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope) at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope) at IronPython.Runtime.PythonContext.InitializeModule(String fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options) at IronPython.Runtime.PythonContext.CompileModule(String fileName, String moduleName, SourceUnit sourceCode, ModuleOptions options, ScriptCode& scriptCode) at IronPython.Runtime.PythonContext.CompileModule(String fileName, String moduleName, SourceUnit sourceCode, ModuleOptions options) at IronPython.Runtime.Importer.LoadFromSourceUnit(CodeContext context, SourceUnit sourceCode, String name, String path) at IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext context, String name, String path) at IronPython.Runtime.Importer.LoadFromDisk(CodeContext context, String name, String fullName, String str) at IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, PythonList path, Func5 defaultLoader)
at IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, PythonList path)
at IronPython.Runtime.Importer.ImportTopAbsolute(CodeContext context, String name)
at IronPython.Runtime.Importer.ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level)
at IronPython.Modules.Builtin.import(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level)
at Microsoft.Scripting.Interpreter.FuncCallInstruction7.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) at System.Dynamic.UpdateDelegates.UpdateAndExecute7[T0,T1,T2,T3,T4,T5,T6,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) at IronPython.Runtime.Importer.ImportLightThrow(CodeContext context, String fullName, PythonTuple from, Int32 level) at IronPython.Runtime.Operations.PythonOps.ImportTop(CodeContext context, String fullName, Int32 level) at Microsoft.Scripting.Interpreter.FuncCallInstruction4.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at IronPython.Compiler.PythonScriptCode.Run(Scope scope)
at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope)
at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink)
at Microsoft.Scripting.SourceUnit.Execute(Scope scope)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at Microsoft.Scripting.Hosting.ScriptEngine.ExecuteFile(String path, ScriptScope scope)
at Microsoft.Scripting.Hosting.ScriptEngine.ExecuteFile(String path)
at Program.Test2() in C:\Work\Solutions\IpyTest\Program.cs:line 37
-------IPY Code: test.py--------------------------------------------------------------------------------
coding=utf-8
import os
print('Test')
-------C# Code:----------------------------------------------------------------------------------------
static class Program
{
[STAThread]
static void Main()
{
var homePath = @"C:\Softwares\IronPython.3.4.1";
List searchPaths = new List()
{
$"{homePath}\Lib",
$"{homePath}\Lib\site-packages"
};
    var pyEngine = Python.CreateEngine();
    pyEngine.SetSearchPaths(searchPaths);
    try
    {
        pyEngine.ExecuteFile(@".\srcpy\test.py");
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
        Console.WriteLine(ex.StackTrace);
    }
}

}

Closing comment (2024-12-08T21:20:28Z): Duplicate of #1811