this has me puzzled; I've created a small test app to show the problem
I'm having.
I want to use subprocess to execute system commands from inside a
Tkinter app running under Cygwin.
When I open a python interpreter and run my subprocess command, all is
well. But when I run the same command from inside a Tkinter app, I'm
getting errors.
I'm using this version of Cygwin:
$ uname -a
CYGWIN_NT-5.1 Mulata 1.5.18(0.132/4/2) 2005-07-02 20:30 i686 unknown unknown Cyg
win
When I run my command in a python shell, all is well:
smidwint@Mulata /cygdrive/c/programs/pipeworksb/lib/python/popt
$ python
Python 2.4.1 (#1, May 27 2005, 18:02:40)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> import subprocess
>>> dirlist = subprocess.Pope n('/usr/bin/ls', shell=True, bufsize=2048, stdout=[/color][/color][/color]
subprocess.PIPE ).stdout[color=blue][color=green][color=darkred]
>>> dirlist[/color][/color][/color]
<open file '<fdopen>', mode 'rb' at 0x49d848>[color=blue][color=green][color=darkred]
>>> for dir in dirlist:[/color][/color][/color]
.... print dir
....
__init__.pyc
browser.bat
test_subprocess .py
test_subprocess .py.bak[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
When I run the same command in a Tkinter app, I get an exception:
smidwint@Mulata /cygdrive/c/programs/pipeworksb/lib/python/popt
$ python test_subprocess .py
d:\cygwin\bin\p ython2.4.exe (7752): *** unable to remap d:\cygwin\bin\t k84.dll t
o same address as parent(0x18C400 00) != 0x18C50000
9 [main] python 4696 fork_parent: child 7752 died waiting for dll loading
Traceback (most recent call last):
File "test_subproces s.py", line 19, in ?
l = Tkinter.Label(t ext=dir_list())
File "test_subproces s.py", line 8, in dir_list
dirlist = subprocess.Pope n('/usr/bin/ls', shell=True, bufsize=2048, stdout=s
ubprocess.PIPE) .stdout
File "/usr/lib/python2.4/subprocess.py", line 558, in __init__
errread, errwrite)
File "/usr/lib/python2.4/subprocess.py", line 918, in _execute_child
self.pid = os.fork()
OSError: [Errno 2] No such file or directory
Here's a sample Tkinter app that reproduces the problem:
#test_subproces s.py
import subprocess, os
import Tkinter
def dir_list():
'''provide a listing of files in a directory'''
#need to know which system to draw from
curdir = os.getcwd()
dirlist = subprocess.Pope n('/usr/bin/ls', shell=True,
bufsize=2048, stdout=subproce ss.PIPE).stdout
#dirlist = subprocess.Pope n(['ls',' -l'],
stdout=subproce ss.PIPE).stdout .communicate()[0]
print dirlist
msgList = []
for dir in dirlist:
print dir
msgList.append( dir)
msg = '\n'.join(msgLi st)
return msg
root = Tkinter.Tk()
l = Tkinter.Label(t ext=dir_list())
l.pack()
b = Tkinter.Button( text='ok',comma nd=root.destroy )
b.pack()
root.mainloop()
BTW, the test_subprocess .py test script that ships with Cygwin python runs fine.
any ideas?
thanks,
--
Stewart Midwinter
stewart@midwint er.ca
stewart.midwint er@gmail.com
Skype, GoogleTalk, iChatAV, MSN, Yahoo: midtoad
AIM:midtoad1
I'm having.
I want to use subprocess to execute system commands from inside a
Tkinter app running under Cygwin.
When I open a python interpreter and run my subprocess command, all is
well. But when I run the same command from inside a Tkinter app, I'm
getting errors.
I'm using this version of Cygwin:
$ uname -a
CYGWIN_NT-5.1 Mulata 1.5.18(0.132/4/2) 2005-07-02 20:30 i686 unknown unknown Cyg
win
When I run my command in a python shell, all is well:
smidwint@Mulata /cygdrive/c/programs/pipeworksb/lib/python/popt
$ python
Python 2.4.1 (#1, May 27 2005, 18:02:40)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright" , "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> import subprocess
>>> dirlist = subprocess.Pope n('/usr/bin/ls', shell=True, bufsize=2048, stdout=[/color][/color][/color]
subprocess.PIPE ).stdout[color=blue][color=green][color=darkred]
>>> dirlist[/color][/color][/color]
<open file '<fdopen>', mode 'rb' at 0x49d848>[color=blue][color=green][color=darkred]
>>> for dir in dirlist:[/color][/color][/color]
.... print dir
....
__init__.pyc
browser.bat
test_subprocess .py
test_subprocess .py.bak[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
When I run the same command in a Tkinter app, I get an exception:
smidwint@Mulata /cygdrive/c/programs/pipeworksb/lib/python/popt
$ python test_subprocess .py
d:\cygwin\bin\p ython2.4.exe (7752): *** unable to remap d:\cygwin\bin\t k84.dll t
o same address as parent(0x18C400 00) != 0x18C50000
9 [main] python 4696 fork_parent: child 7752 died waiting for dll loading
Traceback (most recent call last):
File "test_subproces s.py", line 19, in ?
l = Tkinter.Label(t ext=dir_list())
File "test_subproces s.py", line 8, in dir_list
dirlist = subprocess.Pope n('/usr/bin/ls', shell=True, bufsize=2048, stdout=s
ubprocess.PIPE) .stdout
File "/usr/lib/python2.4/subprocess.py", line 558, in __init__
errread, errwrite)
File "/usr/lib/python2.4/subprocess.py", line 918, in _execute_child
self.pid = os.fork()
OSError: [Errno 2] No such file or directory
Here's a sample Tkinter app that reproduces the problem:
#test_subproces s.py
import subprocess, os
import Tkinter
def dir_list():
'''provide a listing of files in a directory'''
#need to know which system to draw from
curdir = os.getcwd()
dirlist = subprocess.Pope n('/usr/bin/ls', shell=True,
bufsize=2048, stdout=subproce ss.PIPE).stdout
#dirlist = subprocess.Pope n(['ls',' -l'],
stdout=subproce ss.PIPE).stdout .communicate()[0]
print dirlist
msgList = []
for dir in dirlist:
print dir
msgList.append( dir)
msg = '\n'.join(msgLi st)
return msg
root = Tkinter.Tk()
l = Tkinter.Label(t ext=dir_list())
l.pack()
b = Tkinter.Button( text='ok',comma nd=root.destroy )
b.pack()
root.mainloop()
BTW, the test_subprocess .py test script that ships with Cygwin python runs fine.
any ideas?
thanks,
--
Stewart Midwinter
stewart@midwint er.ca
stewart.midwint er@gmail.com
Skype, GoogleTalk, iChatAV, MSN, Yahoo: midtoad
AIM:midtoad1
Comment