How to Install Python

Installing Python 3.9 on Ubuntu from Source

sudo apt update

  1. 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

  2. Download the latest release’s source code from the Python download page(https://www.python.org/downloads/source/) with wget : wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz

  3. Once the download is complete, extract the gzipped archive : tar -xf Python-3.9.1.tgz

  4. 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: cd Python-3.9.0 ./configure --enable-optimizations The –enable-optimizations option optimizes the Python binary by running multiple tests. This makes the build process slower.

  5. Start the Python 3.9 build process: make -j 12 For faster build time, modify the -j to correspond to the number of cores in your processor. You can find the number by typing nproc.

  6. When the build process is complete, install the Python binaries by typing: sudo make altinstall We’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

Previous
Next