Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.NotSupportedException: Encoding 37 data could not be found. (Error on Build) #20

Closed
RainAfterDark opened this issue Sep 26, 2019 · 4 comments
Labels

Comments

@RainAfterDark
Copy link

RainAfterDark commented Sep 26, 2019

This plugin works just fine in the editor, but I get a werid error on the build. The way I'm starting the script goes something like this:

var engine = UnityPython.CreateEngine();
var paths = engine.GetSearchPaths();
// I've copeid the Python folder to StreamingAssets for the libraries to work
paths.Add(Application.streamingAssetsPath + "/Python/Lib");
engine.SetSearchPaths(paths);

try
{
    var source = engine.CreateScriptSourceFromFile(scriptPath);
    source.Compile();
    // script here is a dynamic variable
    script = engine.Runtime.UseFile(scriptPath); // this is where it stops working
    script.GameManager = this;
    script.start();
}
catch (Exception e)
{
    Debug.Log("Error: " + e);
}

The python script I am using uses the threading and Queue libraries, if that helps.

Full Error:

 System.TypeInitializationException: The type initializer for 'CodecsInfo' threw an exception. ---> System.NotSupportedException: Encoding 37 data could not be found. Make sure you have correct international codeset assembly installed and enabled.
   at System.Text.Encoding.GetEncoding (System.Int32 codepage) [0x0023f] in <df7127ba07dc446d9f5831a0ec7b1d63>:0 
   at System.Text.EncodingInfo.GetEncoding () [0x00000] in <df7127ba07dc446d9f5831a0ec7b1d63>:0 
   at IronPython.Runtime.Operations.StringOps+CodecsInfo.MakeCodecsDict () [0x004d1] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Operations.StringOps+CodecsInfo..cctor () [0x00000] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
    --- End of inner exception stack trace ---
   at IronPython.Compiler.Tokenizer.TryGetEncoding (System.Text.Encoding defaultEncoding, System.String line, System.Text.Encoding& enc, System.String& encName) [0x000ea] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.PythonContext.GetSourceReader (System.IO.Stream stream, System.Text.Encoding defaultEncoding, System.String path) [0x000b8] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at Microsoft.Scripting.Runtime.LanguageBoundTextContentProvider.GetReader () [0x0002e] in <b4854a677cbc408eadacd3725c486fb1>:0 
   at Microsoft.Scripting.SourceUnit.GetReader () [0x00000] in <b4854a677cbc408eadacd3725c486fb1>:0 
   at IronPython.Compiler.Parser.CreateParserWorker (Microsoft.Scripting.Runtime.CompilerContext context, IronPython.PythonOptions options, System.Boolean verbatim) [0x00037] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Compiler.Parser.CreateParser (Microsoft.Scripting.Runtime.CompilerContext context, IronPython.PythonOptions options) [0x00000] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.PythonContext.ParseAndBindAst (Microsoft.Scripting.Runtime.CompilerContext context) [0x0000d] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.PythonContext.CompilePythonCode (Microsoft.Scripting.SourceUnit sourceUnit, Microsoft.Scripting.CompilerOptions options, Microsoft.Scripting.ErrorSink errorSink) [0x00026] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.PythonContext.GetScriptCode (Microsoft.Scripting.SourceUnit sourceCode, System.String moduleName, IronPython.Runtime.ModuleOptions options, IronPython.Compiler.CompilationMode mode) [0x0002d] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.PythonContext.GetScriptCode (Microsoft.Scripting.SourceUnit sourceCode, System.String moduleName, IronPython.Runtime.ModuleOptions options) [0x00000] in <0569a20e5dd94f74a766cc11c6214b7c>: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 <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.PythonContext.CompileModule (System.String fileName, System.String moduleName, Microsoft.Scripting.SourceUnit sourceCode, IronPython.Runtime.ModuleOptions options) [0x00000] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.LoadFromSourceUnit (IronPython.Runtime.CodeContext context, Microsoft.Scripting.SourceUnit sourceCode, System.String name, System.String path) [0x00006] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.LoadModuleFromSource (IronPython.Runtime.CodeContext context, System.String name, System.String path) [0x00040] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.LoadFromDisk (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, System.String str) [0x00032] in <0569a20e5dd94f74a766cc11c6214b7c>: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 <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.ImportFromPath (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, IronPython.Runtime.List path) [0x00000] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.ImportTopAbsolute (IronPython.Runtime.CodeContext context, System.String name) [0x00069] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.ImportModule (IronPython.Runtime.CodeContext context, System.Object globals, System.String modName, System.Boolean bottom, System.Int32 level) [0x001da] in <0569a20e5dd94f74a766cc11c6214b7c>: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 <0569a20e5dd94f74a766cc11c6214b7c>: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 <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0004f] in <bdde1939ff4d4d6b828ba549cdd24694>: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 <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at IronPython.Runtime.Importer.ImportLightThrow (IronPython.Runtime.CodeContext context, System.String fullName, IronPython.Runtime.PythonTuple from, System.Int32 level) [0x0002d] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Operations.PythonOps.ImportBottom (IronPython.Runtime.CodeContext context, System.String fullName, System.Int32 level) [0x00000] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at Microsoft.Scripting.Interpreter.FuncCallInstruction`4[T0,T1,T2,TRet].Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0004f] in <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet] (T0 arg0) [0x0003e] in <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at IronPython.Compiler.RuntimeScriptCode.InvokeTarget (Microsoft.Scripting.Runtime.Scope scope) [0x0006a] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Compiler.RuntimeScriptCode.Run (Microsoft.Scripting.Runtime.Scope scope) [0x00000] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.PythonContext.InitializeModule (System.String fileName, IronPython.Runtime.ModuleContext moduleContext, Microsoft.Scripting.ScriptCode scriptCode, IronPython.Runtime.ModuleOptions options) [0x00087] in <0569a20e5dd94f74a766cc11c6214b7c>: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 <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.PythonContext.CompileModule (System.String fileName, System.String moduleName, Microsoft.Scripting.SourceUnit sourceCode, IronPython.Runtime.ModuleOptions options) [0x00000] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.LoadFromSourceUnit (IronPython.Runtime.CodeContext context, Microsoft.Scripting.SourceUnit sourceCode, System.String name, System.String path) [0x00006] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.LoadModuleFromSource (IronPython.Runtime.CodeContext context, System.String name, System.String path) [0x00040] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.LoadFromDisk (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, System.String str) [0x00032] in <0569a20e5dd94f74a766cc11c6214b7c>: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 <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.ImportFromPath (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, IronPython.Runtime.List path) [0x00000] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.ImportTopAbsolute (IronPython.Runtime.CodeContext context, System.String name) [0x00069] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.ImportModule (IronPython.Runtime.CodeContext context, System.Object globals, System.String modName, System.Boolean bottom, System.Int32 level) [0x001da] in <0569a20e5dd94f74a766cc11c6214b7c>: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 <0569a20e5dd94f74a766cc11c6214b7c>: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 <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0004f] in <bdde1939ff4d4d6b828ba549cdd24694>: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 <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at IronPython.Runtime.Importer.ImportLightThrow (IronPython.Runtime.CodeContext context, System.String fullName, IronPython.Runtime.PythonTuple from, System.Int32 level) [0x0002d] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Operations.PythonOps.ImportWithNames (IronPython.Runtime.CodeContext context, System.String fullName, System.String[] names, System.Int32 level) [0x0000a] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at Microsoft.Scripting.Interpreter.FuncCallInstruction`5[T0,T1,T2,T3,TRet].Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0004f] in <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet] (T0 arg0) [0x0003e] in <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at IronPython.Compiler.RuntimeScriptCode.InvokeTarget (Microsoft.Scripting.Runtime.Scope scope) [0x0006a] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Compiler.RuntimeScriptCode.Run (Microsoft.Scripting.Runtime.Scope scope) [0x00000] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.PythonContext.InitializeModule (System.String fileName, IronPython.Runtime.ModuleContext moduleContext, Microsoft.Scripting.ScriptCode scriptCode, IronPython.Runtime.ModuleOptions options) [0x00087] in <0569a20e5dd94f74a766cc11c6214b7c>: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 <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.PythonContext.CompileModule (System.String fileName, System.String moduleName, Microsoft.Scripting.SourceUnit sourceCode, IronPython.Runtime.ModuleOptions options) [0x00000] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.LoadFromSourceUnit (IronPython.Runtime.CodeContext context, Microsoft.Scripting.SourceUnit sourceCode, System.String name, System.String path) [0x00006] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.LoadModuleFromSource (IronPython.Runtime.CodeContext context, System.String name, System.String path) [0x00040] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.LoadFromDisk (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, System.String str) [0x00032] in <0569a20e5dd94f74a766cc11c6214b7c>: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 <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.ImportFromPath (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, IronPython.Runtime.List path) [0x00000] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.ImportTopAbsolute (IronPython.Runtime.CodeContext context, System.String name) [0x00069] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Importer.ImportModule (IronPython.Runtime.CodeContext context, System.Object globals, System.String modName, System.Boolean bottom, System.Int32 level) [0x001da] in <0569a20e5dd94f74a766cc11c6214b7c>: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 <0569a20e5dd94f74a766cc11c6214b7c>: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 <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0004f] in <bdde1939ff4d4d6b828ba549cdd24694>: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 <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at IronPython.Runtime.Importer.ImportLightThrow (IronPython.Runtime.CodeContext context, System.String fullName, IronPython.Runtime.PythonTuple from, System.Int32 level) [0x0002d] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Runtime.Operations.PythonOps.ImportTop (IronPython.Runtime.CodeContext context, System.String fullName, System.Int32 level) [0x00000] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at Microsoft.Scripting.Interpreter.FuncCallInstruction`4[T0,T1,T2,TRet].Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x00000] in <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) [0x0004f] in <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet] (T0 arg0, T1 arg1) [0x0004d] in <bdde1939ff4d4d6b828ba549cdd24694>:0 
   at IronPython.Compiler.PythonScriptCode.RunWorker (IronPython.Runtime.CodeContext ctx) [0x0001b] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Compiler.PythonScriptCode.Run (Microsoft.Scripting.Runtime.Scope scope) [0x00023] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Compiler.RuntimeScriptCode.InvokeTarget (Microsoft.Scripting.Runtime.Scope scope) [0x000c6] in <0569a20e5dd94f74a766cc11c6214b7c>:0 
   at IronPython.Compiler.RuntimeScriptCode.Run (Microsoft.Scripting.Runtime.Scope scope) [0x00000] in <0569a20e5dd94f74a766c<message truncated>
@RainAfterDark RainAfterDark changed the title ystem.NotSupportedException: Encoding 37 data could not be found. (Error on Build) System.NotSupportedException: Encoding 37 data could not be found. (Error on Build) Sep 26, 2019
@exodrifter
Copy link
Owner

exodrifter commented Sep 28, 2019

  • What platform are you targeting?
  • Did you add any additional python libraries, or are you just using what comes in this repository?
  • What does your python script look like? Where does it fail?

A cursory google search suggests that you might not be bundling the correct internationalization code pages when you make your build if you are targeting Android or iOS. I believe you will need to update the generated Android or iOS project build configuration to enable the west localization to include code page 37 in your build.

@RainAfterDark
Copy link
Author

Thanks for the response.

  • I'm building on the windows standalone
  • Nope, just the ones that come with the repo
  • So far, I can only pinpoint that it fails at the line I've commented in the code above.

I've attached the main C# and Python scripts. If that's not sufficient then maybe I can send the whole project folder.

scripts.zip

@exodrifter
Copy link
Owner

exodrifter commented Oct 5, 2019

In the future, it would be nice if you could provide a more minimal example. No worries though, just a heads up for next time as it would make investigating this easier since there are less variables I have to consider.

Generally speaking, if it works in the Editor but not in your build and your target platform is PC/Mac, the Editor is using a DLL that it isn't copied over to the build. In your case, it looks like the threading python library requires the use of the I18N DLLs (not really sure why) like in issue #11. In order to get your build working, here's what you need to do:

  1. Find your Unity Editor installation that you are using for your project and navigate to the following folder:
  • Windows: Unity\Editor\Data\Mono\lib\mono\2.0
  • Mac (Show Package Contents): /Contents/Frameworks/Mono/lib/mono/2.0

Mine happens to be here:

C:\Program Files\Unity\Hub\Editor\2019.2.6f1\Editor\Data\Mono\lib\mono\2.0
  1. Copy the following DLLS:
I18N.CJK.dll
I18N.dll
I18N.MidEast.dll
I18N.Other.dll
I18N.Rare.dll
I18N.West.dll
  1. Add these DLLs to your Plugins folder in your project. If you are not familiar with Special Folders in Unity, please read this manual entry.

Judging by the fact that this is a core python library and this is the second time I've received an issue related to this problem, it seems that these DLLs might be required quite often. I may have to look into making this issue easier to deal with, but it will probably be related to the solution for #21.

@RainAfterDark
Copy link
Author

This seems to fix the problem. Thanks a lot, and yes I'll keep in mind to give simpler examples next time.

Repository owner locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants