geotek
Posts: 15
Joined: Wed Mar 27, 2013 2:57 pm

Running Program Problems

Wed Mar 27, 2013 8:43 pm

Two noobe questions -1). I downloaded a few python programs from Adafruit and when I open them in the console, using sudo ptyhon 'program', they work fine, but if I try and open the program from IDLE3, they will not work/open and get syntax errors, etc. Why is this happening, can I access the program from IDLE32). I obtained two python programs as text and inserted them into IDLE3 and save them as python files but I can't seem to open them either in console mode or in IDLE3, why?Please helpTom

gordon77
Posts: 4992
Joined: Sun Aug 05, 2012 3:12 pm

Re: Running Program Problems

Wed Mar 27, 2013 9:03 pm

Is this the same as this ?
http://www.raspberrypi.org/phpBB3/viewt ... 37#p319137

Gordon77

User avatar
penguintutor
Posts: 386
Joined: Tue May 08, 2012 9:11 am
Location: UK
Contact: Website

Re: Running Program Problems

Thu Mar 28, 2013 10:57 pm

Python 2 vs Python 3.

You have both versions installed on the Pi. When you enter python then it's running 2 (at the moment - this may change in future). To run Python 3 then use python3 on the command line.

You can see this for yourself:

Code: Select all

pi@raspberrypi ~ $ python --version
Python 2.7.3rc2
pi@raspberrypi ~ $ python3 --version
Python 3.2.3
Normally programming languages try to keep backwards compatibility as much as possible, sometimes deprecating a few commands.

In the case of python the decision was made to go for cleaner better code at the expense of breaking backwards compatibility. You can read more here: http://wiki.python.org/moin/Python2orPython3

Return to “Beginners”