How To: Install Python 3.7.3 on Ubuntu Bionic

Note: sudo access is required for this ^__^

As I mentioned in another post, I want to be able to embed Python scripts that use the tk module into my WordPress blog (this website). I started a basic plugin that effectively embeds Python scripts into WordPress posts (yay!) … however I hit a snag when I discovered that my web server does not have the proper dependencies installed to support the code I’m writing. Even as a beginner at Python. D’oh!

Since I’m on a managed hosting platform (DreamHost’s DreamPress) – I don’t have sudo access to install the proper modules with.

Sooooo one of my besties spun me up an Ubuntu Bionic instance (thank you!) on DreamHost’s Cloud hosting platform; DreamCompute…… annnnd since I need Python 3.7 and Bionic comes with 3.6 .. I’m going to go ahead and install Python 3.7 on it … right here, right now.

No one has to know.

Start by logging into your server via SSH as a user with root permissions. If you don’t know how to SSH, you can get started with SSH here. Ultimately, you’ll need to contact your host for login credentials and all that good stuff.

From root, run the following sudo apt command. This updates the Python package list:

 sudo apt update
This will look something like this:

Next, run a sudo apt install command to install packages needed to build out Python source:

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

That is going to start out looking something like this:

…and end up looking something like this:

Moving on …. Use wget to download the latest Python release:

 wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz

Like so:

When that completes, extract the tarball (compressed file) with a tar command:

 tar -xf Python-3.7.3.tar.xz

Then go ahead and navigate into the Python 3.7.3 folder:

 cd Python-3.7.3

Here is what that looks like in my terminal:

Now, we’ll go ahead and run the configure script which runs a series of checks on all dependencies to confirm that all are present.

 ./configure –enable-optimizations

The --enable-optimizations flag optimizes the Python binary by running further tests. This might slow the build process down a bit.

SWEET! Now let’s start building using make:

 make -j 8

You’ll go into the matrix for a few minutes while this builds. Patience is key here friends, just let it run.

Me to my bestie: I’m in ur DreamCompute, building ur Python…

Me, taking a nap while this builds: =^__^= zzZZZzzZZZzzzZZzzzz

Me eating snacks while this bui…….

……Ok so once it’s done building the success output will look like this:

Next! –>>>> Install the Python binaries with another make command:

 sudo make altinstall

If you use a make install you would override the default system python3 binary. So going with an altinstall this time….

Back into the matrix we go!

..annnnnd .. Success! We can turn into a pumpkin now because we are done with our install! Woot!

Verify the installation was a success with a --version flag:

python3.7 —version

The robots should tell you that you’re running Python 3.7.3!

Heck yeah, us!

2 thoughts on “How To: Install Python 3.7.3 on Ubuntu Bionic

Leave a Comment