Difference between revisions of "RPi Debian Python3"

From eLinux.org
Jump to: navigation, search
(Created page with "== Raspberry Pi - Installing Python 3.2.3 on Debian == This guide is aimed at developers, although it can be used by absolute beginners, It is provided as it is realised that t...")
 
m (Numpy .tar permanantly moved to secure protocol 'https://')
 
(21 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== Raspberry Pi - Installing Python 3.2.3 on Debian ==
+
[[Category:RaspberryPi]]
  
This guide is aimed at developers, although it can be used by absolute beginners,  It is provided as it is realised that the latest version of Python is not installed as part of Debian. Other distributions will in future contain this by default.
+
== Installing Python 3.2.3 on Debian Squeeze ==
  
To install the latest version of Python 3.2.3 to Debian:
+
This guide is aimed at developers, although it can be used by beginners if they know what they are after.  It is provided as it is realised that the latest version of Python (3.2) is not available in Debian Squeeze.  Other Linux RPi distributions will in future contain this by default. Note that Raspbian already includes Python 3.
 +
 
 +
To install the latest version of Python (3.2.3) to Debian:
 
<pre>
 
<pre>
 
# install dependencies
 
# install dependencies
Line 30: Line 32:
 
cd ~
 
cd ~
 
</pre>
 
</pre>
 
  
 
== IDLE shortcut in LXDE menu ==
 
== IDLE shortcut in LXDE menu ==
Line 38: Line 39:
 
<pre>
 
<pre>
 
sudo mkdir /usr/local/share/applications
 
sudo mkdir /usr/local/share/applications
sudo nano /usr/local/share/applciations/idle.desktop
+
sudo nano /usr/local/share/applications/idle.desktop
 
</pre>
 
</pre>
  
Line 50: Line 51:
 
GenericName=IDLE
 
GenericName=IDLE
 
StartupNotify=false
 
StartupNotify=false
Categories=Development;IDE;
+
Categories=Development;IDE;</pre>
</pre>
 
 
 
  
 
== Distribute module ==
 
== Distribute module ==
Line 58: Line 57:
 
To install most other Python modules, you will probably want to install the 'distribute' module.  This is a replacement for the now deprecated 'setuptools':
 
To install most other Python modules, you will probably want to install the 'distribute' module.  This is a replacement for the now deprecated 'setuptools':
  
<pre>
+
<pre>wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.26.tar.gz
wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.26.tar.gz
 
 
tar xvfz distribute-0.6.26.tar.gz
 
tar xvfz distribute-0.6.26.tar.gz
 
cd distribute-0.6.26
 
cd distribute-0.6.26
 
sudo python3 setup.py install
 
sudo python3 setup.py install
cd ~
+
cd ~</pre>
</pre>
+
 
 +
== Numpy module ==
 +
This requires a lot of system resources (memory) to build.  Run it with nothing else running - do not run inside X!  You may need to enable swap space.
  
 +
N.B. Takes around 1 hr 40 to build
 +
 +
<pre>wget https://pypi.python.org/packages/source/n/numpy/numpy-1.6.1.tar.gz
 +
tar xvfz numpy-1.6.1.tar.gz
 +
cd numpy-1.6.1
 +
python3 setup.py build
 +
sudo python3 setup.py install
 +
cd ~</pre>
  
 
== PyGame Module ==
 
== PyGame Module ==
  
Watch this space!
+
The latest (stable) release of PyGame does not support Python 3.2 so you have to use the development source.
 +
Make sure that you install the numpy module first.  Note that sound does not work yet - I'll update this guide with instructions when it has been fixed.
 +
 
 +
(Takes around 15 minutes to build).
 +
 
 +
<pre># get pygame source code
 +
sudo apt-get install mercurial
 +
hg clone https://bitbucket.org/pygame/pygame
 +
cd pygame
 +
 
 +
# install dependencies
 +
sudo apt-get install libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev
 +
sudo apt-get install libsmpeg-dev libportmidi-dev libavformat-dev libswscale-dev
 +
 
 +
# build and install pygame
 +
python3 setup.py build
 +
sudo python3 setup.py install</pre>
 +
 
 +
 
 +
== PySide Module ==
 +
 
 +
As an alternative to PyQt you can use the compatible PySide module.
  
 +
# update the apt-get repositories
 +
sudo apt-get update
 +
# get pyside
 +
sudo apt-get install python3-pyside
  
 
== PyQt Module ==
 
== PyQt Module ==
  
 
Watch this space!
 
Watch this space!
 
  
 
== GPIO Module ==
 
== GPIO Module ==
 +
Note that any programs that access GPIO using this module must be run as root.
  
Watch this space!
+
<pre>wget http://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.4.1a.tar.gz
 +
tar xvfz RPi.GPIO-0.4.1a.tar.gz
 +
cd RPi.GPIO-0.4.1a
 +
sudo python3 setup.py install
 +
cd ~</pre>

Latest revision as of 15:45, 21 March 2015


Installing Python 3.2.3 on Debian Squeeze

This guide is aimed at developers, although it can be used by beginners if they know what they are after. It is provided as it is realised that the latest version of Python (3.2) is not available in Debian Squeeze. Other Linux RPi distributions will in future contain this by default. Note that Raspbian already includes Python 3.

To install the latest version of Python (3.2.3) to Debian:

# install dependencies
sudo apt-get install zlib1g-dev
sudo apt-get install libncurses-dev
sudo apt-get install libbz2-dev
sudo apt-get install libreadline-dev
sudo apt-get install sqlite3 libsqlite3-dev
sudo apt-get install libssl-dev
sudo apt-get install libgdbm-dev
sudo apt-get install tk-dev

wget http://www.python.org/ftp/python/3.2.3/Python-3.2.3.tar.bz2
tar xvfj Python-3.2.3.tar.bz2 
cd Python-3.2.3

./configure
# (The 'configure' command takes approx 5 mins)

make
# (The 'make' command takes approx 46 min when you are not running X)

sudo make install
# (The 'make install' command takes approx 5 mins)

cd ~

IDLE shortcut in LXDE menu

To add an idle icon to the programming menu in LXDE:

sudo mkdir /usr/local/share/applications
sudo nano /usr/local/share/applications/idle.desktop

Enter the following file contents:

[Desktop Entry]
Encoding=UTF-8
Exec=idle3 %F
Type=Application
Terminal=false
Name=IDLE
GenericName=IDLE
StartupNotify=false
Categories=Development;IDE;

Distribute module

To install most other Python modules, you will probably want to install the 'distribute' module. This is a replacement for the now deprecated 'setuptools':

wget http://pypi.python.org/packages/source/d/distribute/distribute-0.6.26.tar.gz
tar xvfz distribute-0.6.26.tar.gz
cd distribute-0.6.26
sudo python3 setup.py install
cd ~

Numpy module

This requires a lot of system resources (memory) to build. Run it with nothing else running - do not run inside X! You may need to enable swap space.

N.B. Takes around 1 hr 40 to build

wget https://pypi.python.org/packages/source/n/numpy/numpy-1.6.1.tar.gz
tar xvfz numpy-1.6.1.tar.gz
cd numpy-1.6.1
python3 setup.py build
sudo python3 setup.py install
cd ~

PyGame Module

The latest (stable) release of PyGame does not support Python 3.2 so you have to use the development source. Make sure that you install the numpy module first. Note that sound does not work yet - I'll update this guide with instructions when it has been fixed.

(Takes around 15 minutes to build).

# get pygame source code
sudo apt-get install mercurial
hg clone https://bitbucket.org/pygame/pygame
cd pygame

# install dependencies
sudo apt-get install libsdl-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev 
sudo apt-get install libsmpeg-dev libportmidi-dev libavformat-dev libswscale-dev

# build and install pygame
python3 setup.py build
sudo python3 setup.py install


PySide Module

As an alternative to PyQt you can use the compatible PySide module.

# update the apt-get repositories
sudo apt-get update 
# get pyside
sudo apt-get install python3-pyside

PyQt Module

Watch this space!

GPIO Module

Note that any programs that access GPIO using this module must be run as root.

wget http://pypi.python.org/packages/source/R/RPi.GPIO/RPi.GPIO-0.4.1a.tar.gz
tar xvfz RPi.GPIO-0.4.1a.tar.gz
cd RPi.GPIO-0.4.1a
sudo python3 setup.py install
cd ~