Here is a shell script to install the lastest version of Python under Debian / Raspbian (3.7.4 and Stretch/Buster at the time of writing):
#!/bin/sh RELEASE=3.7.4 # install dependencies sudo apt-get install libbz2-dev liblzma-dev libsqlite3-dev libncurses5-dev libgdbm-dev zlib1g-dev libreadline-dev libssl-dev tk-dev uuid-dev libffi-dev # The following line is required for Buster but will fail harmlessly under Stretch sudo apt-get install libgdbm-compat-dev # download and build Python mkdir ~/python3 cd ~/python3 wget https://www.python.org/ftp/python/$RELEASE/Python-$RELEASE.tar.xz tar xvf Python-$RELEASE.tar.xz cd Python-$RELEASE ./configure --enable-optimizations --enable-shared make sudo make altinstall sudo ldconfig sudo rm -rf ~/python3/Python-$RELEASE cd ~
- Updated to work with both Stretch and Buster
- Updated version of Python and updated dependencies
- ‘make altinstall’ instead of ‘make install’ – note that doing this no longer sets the default python3 to the copy you are building – you have to use python3.x instead. I tend to use virtual environments these days to have better control over the versions in use.
- Added –enable-optimizations to the configure step. This makes builds much slower but you can remove this if you are impatient.
- Added —enable-shared to the configure step. This was needed for mod_wsgi builds and is a default option in Debian package builds anyway.