views:

33

answers:

1

I am calling a python script that uses imaplib.py and get the "no module named fcntl" error. From searching I found that this module is only available in unix and so I wonder if the py script is confused about what os it is running under. Again, script works fine under windows run directly from the python directory.

    var engine = Python.CreateEngine();
    ScriptScope scope = engine.CreateScope();
    var ops = engine.Operations;
    var script = engine.CreateScriptSourceFromFile("PyTest.py");
    CompiledCode code = script.Compile();

    //string scode = script.GetCode();
    code.Execute(scope);

and the minimal py script to trigger it. Note that commenting out the import imaplib.py line will stop the error.

import sys
sys.path = ["Python\Lib"]
sys.platform = ["win32"]

import os
import os
import getopt
import getpass
import time
import imaplib

I traced it a bit to the subprocess.py that imaplib.py uses, there I noticed the sys.platform variable and tried setting it to win32 as above but made no difference. Something is different between the ironpython calling environment and the windows command prompt from the cpython folder.

+1  A: 

First of all you're setting sys.platform to a list, it should be a string. .NET/CLI is a different platform than Win32 though, so just setting sys.platform won't help.

Some Googling suggests IronPython doesn't support the subprocess module (or the module doesn't support IronPython). There is a partial replacement here: http://www.ironpython.info/index.php/The_subprocess_module

There's also a bugreport with some discussion here: http://bugs.python.org/issue8110

adw