Build and Install Python on Raspberrian
How to build and install the latest version of Python on a standard Raspberrian image using the Raspberry Pi.
Tested on Raspberry Pi 3B+ and Raspberrian 4.14.98-v7+.
Special things I've done which improve the speed and reliability of build:
- Used a fast SD card (Samsung class 10).
- Increased the swap size to 2G.
Things that are not standard on Raspberrian that need to be installed:
- bz2 development package
- dbm development package
- lzma development package*
- tkinter development package
- curses development package
- gdbm development package
- sqlite3 development package
- uuid development package
- curses_panel development package
- hashlib development package
- ssl development package
- readline development package
- libffi development package
- python-ctypeslib (may be unnecessary)
The tkinter package is probably not necessary as it is very old despite being standard. There does not appear to be a standard package called dbm. There does not appear to be a standard package called curses_panel. There does not appear to be a standard hashlib package.
Install command:sudo apt install libbz2-dev lzma-dev libncurses5-dev libgdbm-dev libsqlite3-dev uuid-dev libssl-dev libreadline-dev libffi-dev python-ctypeslib
Then download the source and follow the standard python instructions.
Built 3.7.3 successfully with profile guided optimization and without tkinter. All tests passed.
*Still did not build the lzma module in python 3.7.3. Not sure why.