472,781 Members | 1,250 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,781 software developers and data experts.

subprocess problem in cygwin with Tkinter

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
2 4001
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jörg Maier | last post by:
Hey guys, i have a big problem using Tkinter and pexpect in cygwin. i try to program an winscp-like rsync Program for all posix Platforms (linux, macosx, cygwin). i got a class SslConnection...
0
by: Pekka Niiranen | last post by:
Hi, I started cygwin shell with command subprocess.call("c:\\cygwin\\cygwin.bat") from Python 2.4. Shell works fine but the fonts/layout are set according to program...
17
by: Michael McGarry | last post by:
Hi, I am just starting to use Python. Does Python have all the regular expression features of Perl? Is Python missing any features available in Perl? Thanks, Michael
0
by: Pekka Niiranen | last post by:
Hi there I have installed Cygwin to my w2k machine and use Python to execute Bash -shell scripts. I noticed that in script below parameter "shell=False" causes raw_input() to fail; the only way...
4
by: Ivo Woltring | last post by:
Hi Pythoneers, I am trying to make my own gui for mencoder.exe (windows port of the terrific linux mencoder/mplayer) to convert divx to Pocket_PC size. My current app creates a batch script to...
0
by: gh14tq5 | last post by:
Hi, I've recently started learning python programming and have been experimenting with a few basic GUI programs. My work system is cygwin/Windows XP. I use X-windows in cygwin but when I run...
6
by: Eric_Dexter | last post by:
I am having trouble contolling vim with subprocess on a windows machine. It appears that vim comes up on the machine all right and it sometimes looks like it is doing the searchs what I am asking...
7
by: Dave Sampson | last post by:
hey folks, A simple question hopefully. despite all my searching I have not found a satisfactory response. The goal. Interact with a command line program. Simple enough, but the key is...
23
by: Harishankar | last post by:
Hi, Sorry to start off on a negative note in the list, but I feel that the Python subprocess module is sorely deficient because it lacks a mechanism to: 1. Create non-blocking pipes which can...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.