2

I have written a small script that helps me solve scrabble and word-warp problems. It works fine when I run it from Mac OS X terminal. I would like to share the script with my friends as a standalone Mac app. Hence I used py2app for this, but the App crashed when I double-click on it. The console shows the following error message:

1/17/11 2:13:51 PM [0x0-0x4a44a4].org.pythonmac.unspecified.warp[9875] Enter letters: Traceback (most recent call last):
1/17/11 2:13:51 PM [0x0-0x4a44a4].org.pythonmac.unspecified.warp[9875]   File "/Users/***/wordwarp/dist/warp.app/Contents/Resources/__boot__.py", line 137, in <module>
1/17/11 2:13:51 PM [0x0-0x4a44a4].org.pythonmac.unspecified.warp[9875]     _run('warp.py')
1/17/11 2:13:51 PM [0x0-0x4a44a4].org.pythonmac.unspecified.warp[9875]   File "/Users/***/wordwarp/dist/warp.app/Contents/Resources/__boot__.py", line 134, in _run
1/17/11 2:13:51 PM [0x0-0x4a44a4].org.pythonmac.unspecified.warp[9875]     execfile(path, globals(), globals())
1/17/11 2:13:51 PM [0x0-0x4a44a4].org.pythonmac.unspecified.warp[9875]   File "/Users/***/wordwarp/dist/warp.app/Contents/Resources/warp.py", line 4, in <module>
1/17/11 2:13:51 PM [0x0-0x4a44a4].org.pythonmac.unspecified.warp[9875]     word = raw_input("Enter letters: ")
1/17/11 2:13:51 PM [0x0-0x4a44a4].org.pythonmac.unspecified.warp[9875] EOFError: EOF when reading a line
1/17/11 2:13:51 PM warp[9875] warp Error
1/17/11 2:13:51 PM warp[9875] warp Error
1/17/11 2:13:52 PM com.apple.launchd.peruser.501[469] ([0x0-0x4a44a4].org.pythonmac.unspecified.warp[9875]) Exited with exit code: 255

Here is the actual script:

import string

word = raw_input("Enter letters: ")
dict = open('dict.txt')
wordmap = {}
for c in string.lowercase:
    wordmap[c] = 0

for c in word:
    if c in wordmap:
        wordmap[c] = wordmap[c]+1

for line in dict:
    line = line.strip()
    if len(line) >= 3:
        linemap = {}
        for c in string.lowercase:
            linemap[c] = 0
        for c in line:
            if c in linemap:
                linemap[c] = linemap[c]+1
        match = True
        for c in linemap:
            if linemap[c] > wordmap[c]:
                match = False
        if match is True:
            print line

How can I get rid of the error?

1 Answer 1

2

Python programs wrapped as apps by py2app do not have a terminal window from which to enter input. You would need to supply some fancier way of enter input and suppling output, for example by using Python's Tkinter module. If your script runs from the terminal and you want to make a clickable application, it would likely be simpler to package it as an Automater or AppleScript application that launches a Terminal session.

Sign up to request clarification or add additional context in comments.

3 Comments

I see. What would be the easiest way to do this using either Automator or AppleScript (I have never used either before)? There are just two files: warp.py and dict.txt
I haven't used py2app, but would it be acceptable to read word in from a file or a command-line option?
The reason for using py2app in the first place is to produce a standard OS X GUI application that can be launched by double-clicking in the Finder. In that case, there is no command line. If your application is expected to be run from a shell command line, then you most likely shouldn't be using py2app. Just package it with Python Distutils and a console script like most cross-platform Python packages do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.