On 27/06/12 19:05:44, David Thomas wrote:
> Is this why I keep getting an error using launcher?
No.
Yesterday your problem was that you tried this:
input("\n\nPress the enter key to exit")
That works fine in Pyhton3, but you are using python2
and in python2, the you must do this instead:
raw_input("\n\nPress the enter key to exit")
If you still get that error, you can either use "raw_input()"
or switch to Python3, where "input" would be correct.
If you're learning Python from a tutorial, you should
carefully read the first section of the tutorial, where
they mention whether the explains pyhton2 or python3,
and use a matching Python (or a matching tutorial).
If the tutorial doesn't say for which version it is,
then it's for pyhton2 (and several years old).
> Also to open the script in terminal do I need to put
> the following at the beginning of my script:
>
> #!/bin/python
No, that doesn't help.
There are at least three pythons on your system, but
there isn't one in /bin. There are basically two ways
to run a python script in terminal:
Method 1: type the word "python", followed by a space and
the full path to your script, enclosed in quotes, e.g.
python '/Users/dthomaw86/Documents/Python Documents/game_over_enter_key.py'
The quotes are necessary, because you have a space
character in the path.
Method 2:
Step 1: put valid a '#!' line at the top of the script,
for example:
#!/ust/local/bin/python
Step 2: in Terminal, go to the folder where the script is:
cd '/Users/dthomaw86/Documents/Python Documents'
Step 3: make the script "executable"
chmod +x game_over_enter_key.py
Step 4: you can now run the script with:
./game_over_enter_key.py
If you want to run the script again, you only need to repeat
step 4. Or use the "up arrow" key in Terminal.
I think you should pick one method and stick with it, until
you get the hang of Terminal.
> On
python.org it states to To run your script from the Terminal
> window you must make sure that /usr/local/bin is in your shell
> search path.
The installer for Mac from
python.org has installed python2.7
in /Libary/Frameworks/Python.frameworks/Versions/2.7/bin and
added that directory to you shell search path.
If you look at the screen shot, you'll see that the shell
has found python in
/Libary/Frameworks/Python.frameworks/Versions/2.7/bin
Incidentally, you don't have to upload screenshots from
Termimal. You can you just select text in Terminal and
use cmd-C to copy it to the clipboard, and then cmd-V to
paste it to this forum. This is a text-only forum, but
text from Terminal _is_ text, so that's allowed.
For example:
HansM 4$ cat game_over_enter_key.py
raw_input("\n\nPress the enter key to exit")
HansM 5$ python game_over_enter_key.py
Press the enter key to exit
HansM 6$
> Thanks again and I am sorry for all the questions,
> I am just getting started on Python
That's all right: most people run into this sort of issues
when they try their first script. There are usually several
ways to do things, and that leads to you getting conflicting
advice.