Closed
Description
I runned ironpython succesfully on editor runtime. I built succesfully MACOSX from iMac and when I run the game, I got the error in title.
HelloWorld works but my code doesn't work. My code works on Editor mode but not in build runtime :)
I have tried to change API Compatibility Level.
I have installed from unitypackage.
The error comes in this line :
source.Execute(scope);
My Code :
using UnityEngine;
using IronPython.Hosting;
using UnityEngine.UI;
using System;
using System.IO;
using System.Text;
namespace Exodrifter.UnityPython.Examples
{
public class PythonLibrary : MonoBehaviour
{
public TextAsset einsteinPy;
public InputField inputField;
void Start()
{
try
{
var engine = Python.CreateEngine();
var scope = engine.CreateScope();
// Add the python library path to the engine. Note that this will
// not work for builds; you will need to manually place the python
// library files in a place that your code can find it at runtime.
var paths = engine.GetSearchPaths();
paths.Add(Application.streamingAssetsPath + "/PythonLibs");
engine.SetSearchPaths(paths);
string code = @"from constraint import *
problem = Problem()
nationality = ['Danish', 'Spanish', 'Greek']
criteria = nationality
problem.addVariables(criteria,[1, 2, 3])
problem.addConstraint(AllDifferentConstraint(), nationality)
problem.addConstraint(NotInSetConstraint([1]), ['Greek'])
problem.addConstraint(NotInSetConstraint([2]), ['Danish'])
problem.addConstraint(NotInSetConstraint([3]), ['Spanish'])
problem.addConstraint(NotInSetConstraint([3]), ['Danish'])
solution = problem.getSolutions()[0]
result = ''
print len(problem.getSolutions())
for i in range(1,4):
for x in solution:
if solution[x] == i:
result+=str(x) + ' :: ' + str(i) + ' | '";
var source = engine.CreateScriptSourceFromString(code);
source.Execute(scope);
inputField.text += scope.GetVariable<string>("result");
}
catch (Exception ex)
{
inputField.text += ex.Message + "\r\n" + ex.StackTrace;
}
}
}
}
StackTrace :
The type initializer for 'CodecsInfo' threw an exception.
at IronPython.Compiler.Tokenizer.TryGetEncoding (System.Text.Encoding defaultEncoding, System.String line, System.Text.Encoding& enc, System.String& encName) [0x000ea] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.PythonContext.GetSourceReader (System.IO.Stream stream, System.Text.Encoding defaultEncoding, System.String path) [0x000e2] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at Microsoft.Scripting.Runtime.LanguageBoundTextContentProvider.GetReader () [0x0002e] in <d47a77cf2c774bcda41abf48422a59f6>:0
at Microsoft.Scripting.SourceUnit.GetReader () [0x00000] in <d47a77cf2c774bcda41abf48422a59f6>:0
at IronPython.Compiler.Parser.CreateParserWorker (Microsoft.Scripting.Runtime.CompilerContext context, IronPython.PythonOptions options, System.Boolean verbatim) [0x00037] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Compiler.Parser.CreateParser (Microsoft.Scripting.Runtime.CompilerContext context, IronPython.PythonOptions options) [0x00000] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.PythonContext.ParseAndBindAst (Microsoft.Scripting.Runtime.CompilerContext context) [0x0000d] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.PythonContext.CompilePythonCode (Microsoft.Scripting.SourceUnit sourceUnit, Microsoft.Scripting.CompilerOptions options, Microsoft.Scripting.ErrorSink errorSink) [0x00026] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.PythonContext.GetScriptCode (Microsoft.Scripting.SourceUnit sourceCode, System.String moduleName, IronPython.Runtime.ModuleOptions options, IronPython.Compiler.CompilationMode mode) [0x0002d] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.PythonContext.GetScriptCode (Microsoft.Scripting.SourceUnit sourceCode, System.String moduleName, IronPython.Runtime.ModuleOptions options) [0x00000] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.PythonContext.CompileModule (System.String fileName, System.String moduleName, Microsoft.Scripting.SourceUnit sourceCode, IronPython.Runtime.ModuleOptions options, Microsoft.Scripting.ScriptCode& scriptCode) [0x00021] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.PythonContext.CompileModule (System.String fileName, System.String moduleName, Microsoft.Scripting.SourceUnit sourceCode, IronPython.Runtime.ModuleOptions options) [0x00000] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.LoadFromSourceUnit (IronPython.Runtime.CodeContext context, Microsoft.Scripting.SourceUnit sourceCode, System.String name, System.String path) [0x00006] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.LoadModuleFromSource (IronPython.Runtime.CodeContext context, System.String name, System.String path) [0x00040] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.LoadFromDisk (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, System.String str) [0x00032] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.ImportFromPathHook (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, IronPython.Runtime.List path, System.Func`5[T1,T2,T3,T4,TResult] defaultLoader) [0x0007a] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.ImportFromPath (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, IronPython.Runtime.List path) [0x00000] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.ImportModule (IronPython.Runtime.CodeContext context, System.Object globals, System.String modName, System.Boolean bottom, System.Int32 level) [0x0010c] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Modules.Builtin.__import__ (IronPython.Runtime.CodeContext context, System.String name, System.Object globals, System.Object locals, System.Object fromlist, System.Int32 level) [0x0003c] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at (wrapper delegate-invoke) System.Func`7[IronPython.Runtime.CodeContext,System.String,System.Object,System.Object,System.Object,System.Int32,System.Object].invoke_TResult_T1_T2_T3_T4_T5_T6(IronPython.Runtime.CodeContext,string,object,object,object,int)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`7[T0,T1,T2,T3,T4,T5,TRet].Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in <344681103b454854bf549f493ce00237>:0
at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0004f] in <344681103b454854bf549f493ce00237>:0
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) [0x000b1] in <344681103b454854bf549f493ce00237>:0
at IronPython.Runtime.Importer.ImportLightThrow (IronPython.Runtime.CodeContext context, System.String fullName, IronPython.Runtime.PythonTuple from, System.Int32 level) [0x00056] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Operations.PythonOps.ImportWithNames (IronPython.Runtime.CodeContext context, System.String fullName, System.String[] names, System.Int32 level) [0x00008] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at Microsoft.Scripting.Interpreter.FuncCallInstruction`5[T0,T1,T2,T3,TRet].Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in <344681103b454854bf549f493ce00237>:0
at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0004f] in <344681103b454854bf549f493ce00237>:0
at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet] (T0 arg0) [0x0003e] in <344681103b454854bf549f493ce00237>:0
at IronPython.Compiler.RuntimeScriptCode.InvokeTarget (Microsoft.Scripting.Runtime.Scope scope) [0x0006a] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Compiler.RuntimeScriptCode.Run (Microsoft.Scripting.Runtime.Scope scope) [0x00000] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.PythonContext.InitializeModule (System.String fileName, IronPython.Runtime.ModuleContext moduleContext, Microsoft.Scripting.ScriptCode scriptCode, IronPython.Runtime.ModuleOptions options) [0x00087] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.PythonContext.CompileModule (System.String fileName, System.String moduleName, Microsoft.Scripting.SourceUnit sourceCode, IronPython.Runtime.ModuleOptions options, Microsoft.Scripting.ScriptCode& scriptCode) [0x0004f] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.PythonContext.CompileModule (System.String fileName, System.String moduleName, Microsoft.Scripting.SourceUnit sourceCode, IronPython.Runtime.ModuleOptions options) [0x00000] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.LoadFromSourceUnit (IronPython.Runtime.CodeContext context, Microsoft.Scripting.SourceUnit sourceCode, System.String name, System.String path) [0x00006] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.LoadModuleFromSource (IronPython.Runtime.CodeContext context, System.String name, System.String path) [0x00040] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.LoadPackageFromSource (IronPython.Runtime.CodeContext context, System.String name, System.String path) [0x00095] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.LoadFromDisk (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, System.String str) [0x00018] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.ImportFromPathHook (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, IronPython.Runtime.List path, System.Func`5[T1,T2,T3,T4,TResult] defaultLoader) [0x0007a] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.ImportFromPath (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, IronPython.Runtime.List path) [0x00000] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.ImportTopAbsolute (IronPython.Runtime.CodeContext context, System.String name) [0x00069] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.ImportModule (IronPython.Runtime.CodeContext context, System.Object globals, System.String modName, System.Boolean bottom, System.Int32 level) [0x001da] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Modules.Builtin.__import__ (IronPython.Runtime.CodeContext context, System.String name, System.Object globals, System.Object locals, System.Object fromlist, System.Int32 level) [0x0003c] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at (wrapper delegate-invoke) System.Func`7[IronPython.Runtime.CodeContext,System.String,System.Object,System.Object,System.Object,System.Int32,System.Object].invoke_TResult_T1_T2_T3_T4_T5_T6(IronPython.Runtime.CodeContext,string,object,object,object,int)
at Microsoft.Scripting.Interpreter.FuncCallInstruction`7[T0,T1,T2,T3,T4,T5,TRet].Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in <344681103b454854bf549f493ce00237>:0
at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0004f] in <344681103b454854bf549f493ce00237>:0
at Microsoft.Scripting.Interpreter.LightLambda.Run7[T0,T1,T2,T3,T4,T5,T6,TRet] (T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) [0x000a0] in <344681103b454854bf549f493ce00237>:0
at System.Dynamic.UpdateDelegates.UpdateAndExecute6[T0,T1,T2,T3,T4,T5,TRet] (System.Runtime.CompilerServices.CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) [0x00144] in <839a3cb835c04d14aeb58d83bb7bc4bd>:0
at (wrapper delegate-invoke) System.Func`8[System.Runtime.CompilerServices.CallSite,IronPython.Runtime.CodeContext,System.Object,System.String,IronPython.Runtime.PythonDictionary,IronPython.Runtime.PythonDictionary,IronPython.Runtime.PythonTuple,System.Object].invoke_TResult_T1_T2_T3_T4_T5_T6_T7(System.Runtime.CompilerServices.CallSite,IronPython.Runtime.CodeContext,object,string,IronPython.Runtime.PythonDictionary,IronPython.Runtime.PythonDictionary,IronPython.Runtime.PythonTuple)
at IronPython.Runtime.Importer.ImportLightThrow (IronPython.Runtime.CodeContext context, System.String fullName, IronPython.Runtime.PythonTuple from, System.Int32 level) [0x0002d] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Importer.Import (IronPython.Runtime.CodeContext context, System.String fullName, IronPython.Runtime.PythonTuple from, System.Int32 level) [0x00000] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Runtime.Operations.PythonOps.ImportStar (IronPython.Runtime.CodeContext context, System.String fullName, System.Int32 level) [0x00015] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at Microsoft.Scripting.Interpreter.ActionCallInstruction`3[T0,T1,T2].Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in <344681103b454854bf549f493ce00237>:0
at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0004f] in <344681103b454854bf549f493ce00237>:0
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet] (T0 arg0, T1 arg1) [0x0004d] in <344681103b454854bf549f493ce00237>:0
at IronPython.Compiler.PythonScriptCode.RunWorker (IronPython.Runtime.CodeContext ctx) [0x0001b] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Compiler.PythonScriptCode.Run (Microsoft.Scripting.Runtime.Scope scope) [0x00023] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Compiler.RuntimeScriptCode.InvokeTarget (Microsoft.Scripting.Runtime.Scope scope) [0x000c6] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at IronPython.Compiler.RuntimeScriptCode.Run (Microsoft.Scripting.Runtime.Scope scope) [0x00000] in <6e95101e82ea4feb8f6d4cc1271fa904>:0
at Microsoft.Scripting.SourceUnit.Execute (Microsoft.Scripting.Runtime.Scope scope, Microsoft.Scripting.ErrorSink errorSink) [0x0001e] in <d47a77cf2c774bcda41abf48422a59f6>:0
at Microsoft.Scripting.SourceUnit.Execute (Microsoft.Scripting.Runtime.Scope scope) [0x00000] in <d47a77cf2c774bcda41abf48422a59f6>:0
at Microsoft.Scripting.Hosting.ScriptSource.Execute (Microsoft.Scripting.Hosting.ScriptScope scope) [0x00017] in <d47a77cf2c774bcda41abf48422a59f6>:0
at (wrapper remoting-invoke-with-check) Microsoft.Scripting.Hosting.ScriptSource.Execute(Microsoft.Scripting.Hosting.ScriptScope)
at Exodrifter.UnityPython.Examples.PythonLibrary.Start () [0x0003f] in <ce76bbd974a1440e9790fb7ad4399d31>:0