Der folgende Import funktioniert innerhalb der Eingabeaufforderung ipy.exe, schlägt aber mit IronPython ScriptRuntime in einem C# 4.0-Programm fehl.IronPython ScriptRuntime entspricht CPython PYTHONPATH
import ConfigParser
C# -Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;
namespace CSharpDynamic
{
class Program
{
static int Main(string[] args)
{
ScriptRuntime python = Python.CreateRuntime();
dynamic dynamicIni =
python.UseFile(@"c:\test\WebCast\DynamicIni.py");
return 0;
}
}
}
CPython verwendet PYTHONPATH-Umgebungsvariable. Wie konfiguriere ich dies in IronPython bei Verwendung von ScriptRuntime?
Der IronPython-Interpreter (ipe.exe) verwendet die Umgebungsvariable IRONPYTHONPATH. Je nach Anwendung kann es sinnvoll sein, dies auch in SetSearchPaths zu lesen. –