rodrigosantosbr

Installing Python 3.8 on Ubuntu from Source

Jul 25th, 2021 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!

Update the packages list and install the packages 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

Download the latest release’s source code from the Python download page using wget :

wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
When the download finishes, extract the gzipped archive :

tar -xf Python-3.8.0.tgz

Switch to the Python source directory and execute the configure script which performs a number of checks to make sure all of the dependencies on your system are present:

cd Python-3.8.0
./configure --enable-optimizations

The --enable-optimizations option optimizes the Python binary by running multiple tests. This makes the build process slower.

Start the Python 3.8 build process:

make -j 8
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.

When the build process is complete, install the Python binaries by typing:

sudo make altinstall
Do not use the standard make install as it will overwrite the default system python3 binary.

That’s it. Python 3.8 has been installed and ready to be used. Verify it by typing:

python3.8 --version

which python3.8
/usr/local/bin/python3.8

deactivate
poetry env use /usr/local/bin/python3.8
poetry shell

Add Comment
Please, Sign In to add comment