dalpets
Posts: 5
Joined: Fri Nov 16, 2012 12:37 pm

Upgrading Python

Fri Nov 16, 2012 12:52 pm

I am using the default Debian software on the RPI.
I recently ordered & have received a book on Python programming for the RPI, however, the programming used in the book is based on Idle Python 3.1.3 but my RPI only has v 2.6.6

I have made a number of attempts at the command line to install the later version without success. It complains there are missing dependancies/libraries & aborts.

Could someone give this greenhorn some detailed help on how to successfully upgrade. Thanks.

techpaul
Posts: 1512
Joined: Sat Jul 14, 2012 6:40 pm
Location: Reading, UK
Contact: Website

Re: Upgrading Python

Fri Nov 16, 2012 2:20 pm

dalpets wrote:I am using the default Debian software on the RPI.
I recently ordered & have received a book on Python programming for the RPI, however, the programming used in the book is based on Idle Python 3.1.3 but my RPI only has v 2.6.6

I have made a number of attempts at the command line to install the later version without success. It complains there are missing dependancies/libraries & aborts.

Could someone give this greenhorn some detailed help on how to successfully upgrade. Thanks.
Do a double check as most distros have python and python 3

At command prompt what happens if you type python3 ?

Some distros have IDLE3 for python3 version. Raspbian default has
Just another techie on the net - For GPIO boards see http:///www.facebook.com/pcservicesreading
or http://www.pcserviceselectronics.co.uk/pi/

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

Re: Upgrading Python

Fri Nov 16, 2012 3:22 pm

I have just loaded the latest Raspian on my RPi and its got python v2.7 and v3.2.

I converted another PC to Debian 6 and it has v2.6.6 and v3.1, very confusing

Gordon

BlackJack
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
Contact: Website

Re: Upgrading Python

Fri Nov 16, 2012 4:27 pm

@gordon77: Raspbian is based on Debian 7 (code name Wheezy) so it should not be so surprising it has newer versions of some packages than Debian 6 (code name Squeeze).

Code: Select all

while not self.asleep():
    sheep += 1

User avatar
fdion
Posts: 307
Joined: Sun Sep 16, 2012 2:33 pm
Location: North Carolina, USA
Contact: Website

Re: Upgrading Python

Fri Nov 16, 2012 4:29 pm

The OS itself usually rely on a python 2.x series for some of its functionality. Some actually have 2.4... But from 2.6 onward (2.6.x or 2.7.x) it is pretty much equivalent. Python 2.7 does introduce a few things to help transition to 3.x and some import from future of functionality from 3.x. Also has dictionary comprehension (whereas 2.6.x only has list comprehension).

python 3 is normally explicitely run by using python3 instead of python (ie #!/usr/bin/env python3 ).

There will continue to be this duality for a long time. Minor rev differences rarely make any difference in code compatibility.


Francois
Francois
http://raspberry-python.blogspot.com - http://www.3dFutureTech.info - @f_dion

User avatar
Forrrge
Posts: 120
Joined: Fri Apr 27, 2012 6:07 am
Location: Gateshead, UK.

Re: Upgrading Python

Fri Nov 16, 2012 5:39 pm

What you could do is run Python through the Geany IDE
sudo apt-get install geany

Then once its installed you need to make a change in its config so that Python 3 is run be default, see post below
http://www.raspberrypi.org/phpBB3/viewt ... 32&t=20746

dalpets
Posts: 5
Joined: Fri Nov 16, 2012 12:37 pm

Re: Upgrading Python

Sat Nov 17, 2012 11:30 am

Thanks for all comments thus far.

Perhaps I should repeat that I want to use Idle, because that is what the text book I have purchased is working with.
When I type Python3 in the terminal the response is;
"Python 3.2.3 (default Nov 7, 2012)
[GCC 4.4.4] on linux 2"
So, it appears one of my download attempts must have worked.

How, if possible can I get Idle to see the 3.2.3 in lieu of the 2.6.6 which it presently is using or is this a separate download.

Edit: I just noticed on Distro Watch that Debian has the following python packages;

marked Python 3.3.0???
unstable sid 2.7.3
testing Wheezy 2.7.3rc2
squeeze 6 2.6.6

Does that mean that I am out of luck with Debian to run 3.2.3: if so it does beg the question of how the author of the text book is using 3.1.3

Thanks

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

Re: Upgrading Python

Sat Nov 17, 2012 1:50 pm

I'm no expert at this but on my RPi GUI there is an icon called 'IDLE 3'. which if I double click it runs a Python Shell and it's Python 3.2.3, is that what you need ?

BlackJack
Posts: 288
Joined: Sat Aug 04, 2012 8:28 am
Contact: Website

Re: Upgrading Python

Sat Nov 17, 2012 9:01 pm

@dalpets: As 3.1 is the Python 3 available in Debian 6 I guess the author has used Debian 6. If he used Debian, or even Linux at all.

Just go with Raspbian and the 3.2.3 installed there along with IDLE called IDLE3 as gordon77 pointed out. You really don't have to match the version exactly as long as the major version is the same. Especially if the installed Python has a higher version number than the one in the book, there should be no problem. The jump from Python 2 to Python 3 breaks backwards compatibility which is some kind of a big deal in Python world because backwards compatibility is quite important to the Python language developers.

Code: Select all

while not self.asleep():
    sheep += 1

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

Re: Upgrading Python

Sun Nov 18, 2012 9:57 am

"by BlackJack » Fri Nov 16, 2012 5:27 pm
@gordon77: Raspbian is based on Debian 7 (code name Wheezy) so it should not be so surprising it has newer versions of some packages than Debian 6 (code name Squeeze)."


Thanks for the info. Unfortunately I don't seem to be able to run Debian Wheezy on my Dell PC. 6 works fine but wheezy seems to load OK but at bootup I just half a screen of 'noise'. :(

dalpets
Posts: 5
Joined: Fri Nov 16, 2012 12:37 pm

Re: Upgrading Python

Mon Nov 19, 2012 11:10 am

The problem has been solved by setting up Wheezy (3.2.3) on the SD card in lieu of Squeeze (2.6.6).
Thanks all for your help.

Return to “Python”

Who is online

Users browsing this forum: MrYsLab, pcmanbob and 11 guests