ImportException when importing built-in libraries in Windows Service #1668
JBensonNBT
started this conversation in
General
Replies: 1 comment 3 replies
-
It sounds like it might be failing to load the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm building a Windows Service using IronPython 3.4 to process scripts. I have discovered strange behavior when running scripts in my service that don't occur in a standard Windows console app.
The following examples always generate an ImportException in the service:
Python line: "import time"
Python line: "from time import *"
IronPython C# (scope = ScriptScope): "scope.ImportModule("time")
Similar exceptions occur for other built-in modules (e.g. math).
The same examples execute properly in standard Windows running under my user account. My Windows service is running under the Local Service account. The runtime environment seems to be the major difference between success and failure.
I am new to IrionPython so it's certainly possible I'm doing something wrong settiing things up:
ScriptEngine pythonEngine = Python.CreateEngine();
ScriptSource pythonScript = pythonEngine.CreateScriptSourceFromString(script.Script, SourceCodeKind.AutoDetect);
pythonScript.Execute(scope);
ImportException always occurs on the Execute(scope) step if the Python script includes an "import" either specifically in my code or inside a .py file imported from the standard libarary.
Here is an example of the Windows exception stack:
Ironpython_time_import_exception.txt
This is turning out to be a showstopper. Anyone have ideas how to overcome the problem? IronPython bug maybe?
Thanks
Jeff
Beta Was this translation helpful? Give feedback.
All reactions