Installing Python on Linux isn't so hard. These are my notes for installing on Ubuntu.
- Install build dependencies using apt.
- Choose and download the version of Python you'd like to install from the releases page.
- Extract the directory
- Run
./configureandmaketo install
You will need some dependencies, listed in the development guide.
There are some configuration options. We install to .local for a user
install of Python, and use make altinstall to install alongside any
existing Python installations.
Example steps:
sudo apt-get install build-essential gdb lcov pkg-config \
libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev \
libncurses5-dev libreadline6-dev libsqlite3-dev libssl-dev \
lzma lzma-dev tk-dev uuid-dev zlib1g-dev
export VERSION=3.9.5
curl "https://www.python.org/ftp/python/${VERSION}/Python-${VERSION}.tgz" | tar -xzf -
cd ${VERSION}
./configure --prefix=$HOME/.local/ --enable-optimizations --with-lto
make
make test
make altinstallI've also made a script that automates some of the above steps.
Usage:
./install_py.sh 3.10.11 7e25e2f158b1259e271a45a249cb24bb
# OR
PYTHON_VERSION=3.10.11 PYTHON_MD5SUM=7e25e2f158b1259e271a45a249cb24bb ./install_py.shAfter make, you might see some modules can't be found. In that case, you may need to install the dependencies via apt or from source. (OpenSSL especially)