IronPythonをC#ScriptEngineとして使用しているときに、PyroまたはPyro4をインポートする際に問題が発生しています。IronPython ScriptEngineでPyroをインポートする
ipyインタープリタで直接実行すると正常にインポートされますが、ipyがc#スクリプトからスクリプトエンジンとして初期化されると、次のエラーが発生します。 FullFramesと-X::それは初期化がすでにだ時にフレームパラメータがIPYするので、私は、私はそれを除外していると信じて
TypeErrorException: sequence item 0: expected bytes or byte array, str found
IronPython.Runtime.Operations.ByteOps.AppendJoin (System.Object value, Int32 index, System.Collections.Generic.List`1 byteList)
IronPython.Runtime.Bytes.join (System.Object sequence)
Microsoft.Scripting.Interpreter.FuncCallInstruction`3[IronPython.Runtime.Bytes,System.Object,IronPython.Runtime.Bytes].Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame)
Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame)
私は-Xを渡しています。実際、このエラーは、このパラメータで初期化するかどうかにかかわらず発生します。
// Set the fullframes parameter in a dict
var options = new Dictionary<string, object>();
options["Frames"] = true;
options["FullFrames"] = true;
// create the engine
var ScriptEngine = IronPython.Hosting.Python.CreateEngine(options);
// and the scope (ie, the python namespace)
var ScriptScope = ScriptEngine.CreateScope();
//set the python file to execute
string scriptPath = "Assets\\test.py";
var ScriptSource = ScriptEngine.CreateScriptSourceFromFile(scriptPath);
そして、もちろん、Pythonスクリプトでは、私はパイロのインポート時に、このエラーが発生します:ここで
は、C#で私のコードです。
import Pyro
このエラーは一般にIPYでの作業には鈍いです。私は困惑しています。 少しのトレースバックを得るためのテクニックも含め、洞察力があれば、大きな助けになるでしょう。
ありがとうございます!
IronPythonでは文字列がユニコードであり、これは問題の根本となるかもしれません。しかし、これはまだ、このコードが標準のipy.exeでは実行されますが、ScriptEngineでは実行されない理由を説明していません。 – karmakat