How to Install Python
Installing Python 3.9 on Ubuntu from Source
sudo apt update
Install the dependencies necessary to build Python:
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev -y
Download the latest release’s source code from the Python download page(https://www.python.org/downloads/source/) with
Once the download is complete, extract the gzipped archive :
tar -xf Python-3.9.1.tgz
Switch to the Python source directory and run the configure script, which performs a number of checks to make sure all of the dependencies on your system are present:
./configure --enable-optimizationsThe –enable-optimizations option optimizes the Python binary by running multiple tests. This makes the build process slower.
Start the Python 3.9 build process:
make -j 12For faster build time, modify the -j to correspond to the number of cores in your processor. You can find the number by typing
When the build process is complete, install the Python binaries by typing:
sudo make altinstallWe’re using altinstall instead of install because later will overwrite the default system python3 binary.
Side Note: complier error has occured on my raspberry pi 3, using core 4