Building Python on the Raspberry Pi2
# Condensed and revised from Blake's site (unreachable currently): | |
# http://sowingseasons.com/blog/building-python-3-4-on-raspberry-pi-2.html | |
# Install prerequisites | |
sudo apt-get update | |
sudo apt-get upgrade -y | |
sudo apt-get install -y \ | |
build-essential libncursesw5-dev libgdbm-dev libc6-dev \ | |
zlib1g-dev libsqlite3-dev tk-dev libssl-dev openssl \ | |
libreadline6-dev liblzma-dev libbz2-dev libdb-dev | |
# Perhaps libreadline-dev will just as well above | |
# Choose a version: | |
# Set version (3.4) | |
export MYPYMAJ=3 | |
export MYPYMIN=4 | |
export MYPYPNT=3 | |
# Set version (3.5) | |
export MYPYMAJ=3 | |
export MYPYMIN=5 | |
export MYPYPNT=1 | |
# Set version (2.7) | |
export MYPYMAJ=2 | |
export MYPYMIN=7 | |
export MYPYPNT=11 | |
# Get sources and build locally | |
export MYPYVER=${MYPYMAJ}.${MYPYMIN}.${MYPYPNT} | |
export MYPYREL=${MYPYMAJ}.${MYPYMIN} | |
mkdir -p ~/Projects | |
cd ~/Projects | |
wget --continue https://www.python.org/ftp/python/${MYPYVER}/Python-${MYPYVER}.tgz | |
tar -zxvf Python-${MYPYVER}.tgz | |
cd Python-${MYPYVER} | |
./configure | |
make -j 4 | |
# Install any missing deps and run 'make' again. | |
# For the completists: | |
# Python 2.7 will warn about 'sunaudiodev' - ignore it: | |
# https://docs.python.org/2/library/sunaudio.html | |
# Likewise the ancient 'bsddb185' apparently can be ignored as well | |
# Alt install so we don't clobber the system's Python version! | |
# But whyyyyyy? http://stackoverflow.com/questions/16018463/difference-in-details-between-make-install-and-make-altinstall | |
# Details: https://hg.python.org/cpython/file/3.5/README#l149 | |
# | |
# But, note that while 'python2' will still refer to the system's Python 2.7, 'python2.7' will now refer to yours! | |
# Presumably the same would be true for Python 3.2 were you to altinstall that. | |
# Pip will be similarly affected. | |
sudo make altinstall | |
# Test the Python you installed | |
python${MYPYREL} | |
# Check if Pip works already | |
pip${MYPYREL} --version | |
# If not, get Pip (superfluous anymore...) | |
cd ~/Projects | |
rm get-pip.py | |
wget https://bootstrap.pypa.io/get-pip.py | |
sudo python${MYPYREL} get-pip.py | |
pip${MYPYREL} --version | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
I've learned that gist has a major old bug wherein you don't get notifications for comments to gists.
If you leave a comment, it would be appreciated if you ping me elsewhere so I know to find it!