subprocess problem in cygwin with Tkinter

  • Thread starter Stewart Midwinter
  • Start date
S

Stewart Midwinter

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..... print dir
....
__init__.pyc
browser.bat
test_subprocess.py
test_subprocess.py.bak

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\python2.4.exe (7752): *** unable to remap d:\cygwin\bin\tk84.dll t
o same address as parent(0x18C40000) != 0x18C50000
9 [main] python 4696 fork_parent: child 7752 died waiting for dll loading
Traceback (most recent call last):
File "test_subprocess.py", line 19, in ?
l = Tkinter.Label(text=dir_list())
File "test_subprocess.py", line 8, in dir_list
dirlist = subprocess.Popen('/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_subprocess.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.Popen('/usr/bin/ls', shell=True,
bufsize=2048, stdout=subprocess.PIPE).stdout
#dirlist = subprocess.Popen(['ls',' -l'],
stdout=subprocess.PIPE).stdout.communicate()[0]
print dirlist
msgList = []
for dir in dirlist:
print dir
msgList.append(dir)
msg = '\n'.join(msgList)
return msg

root = Tkinter.Tk()
l = Tkinter.Label(text=dir_list())
l.pack()
b = Tkinter.Button(text='ok',command=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
(e-mail address removed)
(e-mail address removed)
Skype, GoogleTalk, iChatAV, MSN, Yahoo: midtoad
AIM:midtoad1
 
A

AdSR

Stewart said:
[...]
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 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\python2.4.exe (7752): *** unable to remap d:\cygwin\bin\tk84.dll t
o same address as parent(0x18C40000) != 0x18C50000
9 [main] python 4696 fork_parent: child 7752 died waiting for dll loading
[...]
any ideas?

This is a dll problem that sometimes happens in Cygwin. Run 'rebaseall'
to fix this.

HTH,
AdSR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,037
Messages
2,570,371
Members
47,013
Latest member
JewellChes

Latest Threads

Top