TIGSource Forums

Developer => Technical => Topic started by: Jared C on June 11, 2009, 12:46:09 PM



Title: Trouble Running Python on Mac 0SX 10
Post by: Jared C on June 11, 2009, 12:46:09 PM
Hey guys,  ;D

I've finally started ANOTHER endeavor, and am now learning Python. Only problem is, I can't get it to run on Mac.  I downloaded and installed the Python 3.0.1 folder, but when I open IDLE and type in anything (but mathematical equations) I get error messages. Does anyone here have experience with Python on Mac?  Any help is appreciated.


Title: Re: Trouble Running Python on Mac 0SX 10
Post by: Ivan on June 11, 2009, 01:00:31 PM
OSX comes with python by default (Since Tiger I think), so you shouldn't have to install anything. What exactly errors are you getting?

You need to provide more clear information about the problem.


Title: Re: Trouble Running Python on Mac 0SX 10
Post by: Jared C on June 11, 2009, 01:33:27 PM
I guess the problem would be nothing associated with Python is working correctly, including IDLE, Launcher, etc.  The exact error I keep getting is this-  SyntaxError: invalid syntax (<pyshell#0>, line 1)

Python in  Terminal isn't even working right.  :wtf:


Title: Re: Trouble Running Python on Mac 0SX 10
Post by: Joshua on June 12, 2009, 02:32:08 PM
Since it looks like you are using Python 3.0 (or 3000 as its sometimes called) be aware that some of the syntax has changed from the previous (python 2.6) version. For example:

Code: (Python Shell)
>>>print "Hello world!"

Will work just fine in python 2.x. But in python 3.x you get a: SyntaxError: invalid syntax (<pyshell#0>, line 1).
The python 3.x equivalent is:

Code: (Python Shell)
>>>print("Hello world!")

From my experience, most tutorials you will find on the internet apply to python 2.6 (or earlier). If you need any help, feel free to pick my brain.

Also it is common practice write python script in a file and then execute the file.

Code: (example.py)
dwarf_list = ["Dopey","Grumpy","Doc","Happy","Bashful","Sneezy","Sleepy"]

for dwarf in dwarf_list:
    print("My name is: " + dwarf)


Title: Re: Trouble Running Python on Mac 0SX 10
Post by: Jared C on June 12, 2009, 03:18:49 PM
Oh, wow, thank you so much Joshua! I'm no to the whole coding thing, so I really appreciate it.
Now that I actually have an idea of what I'm doing, beware; I will not hesitate to contact you.  :P