[IronPython] import subprocess

Matthew S Bourdua bourduam at msu.edu
Thu Jul 5 21:49:57 CEST 2007


I have a question about the "subprocess" module.  I am unable to "import 
subprocess" in my scripts.  Will IronPython will support this in the future, 
or, perhaps is it intentionally not supported?  (Or perhaps I am doing 
something stupid, and it should work?) 

I recently began using IronPython because I had both Python scripts and .Net 
classes that I needed to use together.  So far I have been pretty pleased 
with how well everything is working. 

My biggest problem has been that the os.system() call does not work in 
IronPython.  I notice that this was raised as an issue in Sep '06 
While hunting around for an alternative, I found the following text in the 
library reference (http://docs.python.org/lib/module-subprocess.html): 

"The subprocess module ... intends to replace several other, older modules 
and functions, such as: 


For this reason, I thought that perhaps "os.system" was going to become 
deprecated in favor of "subprocess", and that might explain why this issue 
has not been addressed. 

However, I am unable to "import subprocess" in IronPython.  When I do so, an 
exception is raised because, "No module named fcntl".  Digging into this a 
bit, I notice the following variable defined within subprocess.py (this is 
from ActivePython 2.5): 

mswindows = (sys.platform == "win32") 

And then many conditional statements of the form:
if mswindows:
...#Windows specific code
...#Non-windows code, presumably 

IronPython fails this check because sys.platform = 'cli', and thus is lead 
into using modules that are (I would guess) meant for Unix-based systems. 

Further, this behavior seems to be known - I noticed that this seemed to be 
accounted for in (what appears to be) the automatic test-suite code located 

What's strange to me is that I couldn't find a single reference to using 
subprocess in IronPython anywhere.  So perhaps this issue is widely 
understood by everybody but me (I'm relatively new to Python), or simply not 
an issue for anybody but me? 

Anyway, I was hoping somebody on this mailing list might have some insight 
to share. 


More information about the Ironpython-users mailing list