How To Install Python on Bluehost

While recently working on some Python projects, I realized that I needed to move those very projects over to my hosting setup. Upon inspecting said setup, I immediately I found that my Bluehost hosting setup didn’t have the latest version of Python installed so we would have to figure out how to install it ourselves. Thankfully, installing Python on Bluehost is pretty simple and Bluehost has some very clear Python installation instructions available on their site,  but we’re going to document the installation steps here anyway for everyone’s enjoyment.

Preparation

Before beginning, you will need to do 2 things:

1. ssh access
If you don’t already have ssh access, you can enable it by logging into your cpanel and then follow these basic instructions on how to enable ssh access.

2. Ensure that your cPanel user has been added to the C compiler group on the server.
If your cPanel user is not part of the C compiler group, you will get this error when trying to install Python when following the steps that I outlined below. To resolve this, contact Bluehost support by phone or by chat and they will set you up.

configure: error: in `/home2/tomstec2/Python_3.9.2/Python-3.9.2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

Once the above has been taken care of, proceed to the following installation steps.

Download the latest version of Python

To begin, ssh over to your server and follow these steps to create a directory and download and untar Python into the directory you just created:

mkdir ~/python
cd ~/python
wget http://www.python.org/ftp/python/3.9.2/Python-3.9.2.tgz
tar zxfv Python-3.9.2.tgz
find ~/python -type d | xargs chmod 0755
cd Python-3.9.2

Run the Python Installation

Once you’ve extracted Python into the folder that you created, you’ll need to execute the installation. This will take a bit of time. Run the following commands:

./configure --prefix=$HOME/python
make
make install

Configure .bashrc

Finally, add python to your local path in .bashrc

Use your favorite editor to edit your .bashrc:

vim ~/.bashrc
Add the following line
export PATH=$HOME/python/Python-3.9.2/:$PATH
Save the changes and quit and the run:
source ~/.bashr

Check version of Python installed

Log out and log back in and then check what version of Python is installed. If everything went well, you should see:
python -V
Python 3.9.2

3 thoughts on “How To Install Python on Bluehost

  1. Thanks for the instructions. I have python installed as above, but can’t get it to run scripts from a web page using the latest version of python when I add the path to the new python to the first line of my script. Thanks for any help.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.