By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,677 Members | 1,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,677 IT Pros & Developers. It's quick & easy.

subprocess problem in cygwin with Tkinter

P: n/a
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.
import subprocess
dirlist = subprocess.Popen('/usr/bin/ls', shell=True, bufsize=2048, stdout= subprocess.PIPE).stdout dirlist <open file '<fdopen>', mode 'rb' at 0x49d848> for dir in dirlist: .... 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
st*****@midwinter.ca
st***************@gmail.com
Skype, GoogleTalk, iChatAV, MSN, Yahoo: midtoad
AIM:midtoad1
Jan 5 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Stewart Midwinter wrote:
[...]
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

Jan 5 '06 #2

P: n/a
that's it! Thanks, that sorted me out. The readme at the following
location was very helpful:
http://www.tishler.net/jason/softwar...ase-2.2.README
I couldn't get rebaseall to work until I installed all of the packages
mentioned in the readme.

Now I have a different problem, regarding Pmw menus, but I've posted a
separate item on that. thanks again.

Jan 5 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.