How to Install Python on a Hosting Server
Python is a flexible and easy-to-use programming language widely used by developers and professionals for its adaptability. In this guide, we'll explain how to install Python on a hosting server.
What are the Requirements for Running Python on a Hosting Server?
To execute a Python application on a hosting server, you'll need the right hosting environment. Bluehost offers a range of options suitable for Python development, including VPS, Dedicated servers, and various Shared hosting plans.
Can I Install Python on Bluehost?
Yes, Python is preinstalled on Bluehost with CentOS, but it may not be the latest version. To install Python on your computer, you need to be in the Compiler group. To join, call our Support team at 888-401-4678 and request access.
Python File Extension
Python scripts use the .py file extension (for example, script.py). The script must have 755 permission.
Python Script example
Below is a basic example of a Python CGI script that outputs a simple HTML page:
#!/usr/bin/python3
print("Content-type: text/html\n")
print("<html><head>")
print("<title>CGI Test</title>")
print("</head><body>")
print("<p>Test page using Python</p>")
print("</body></html>")
Step-by-step Guide to Install Python 3.9 on Bluehost
Python Download
Here’s how to install Python 3.9.2. Use these commands to download and extract Python 3.9.2 to your hosting account.
- Visit the Index of Python.org/ftp/ to find the Python version you want.
- Check the Status of Python Versions page for details about the latest release and when older versions will no longer be supported.
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
Python Installation
After you extract the files, run these commands to set up and install Python.
./configure --prefix=$HOME/python
make
make install
Modify the .bashrc
To ensure your local Python version loads, add it to your .bashrc file.
vim ~/.bashrc
Press i, then enter:
export PATH=$HOME/python/Python-3.9.2/:$PATH
Write the changes (press ESC) and close vim:
:wq
Press Enter
source ~/.bashrc
- You might need to log out so the environment can update.
- Type python -V to see which version of Python is installed.
Python Installation Error
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
If you see the configuration error above while trying to set up Python with ./configure --prefix=$HOME/python, your cPanel user likely is not part of the C compiler group on the server. Please call our Support team at 888-401-4678 and ask to be added to the Compiler group.
Summary
This guide will show you how to download and install Python. For the best performance and compatibility, please use the latest version. Before you start, contact the support team so they can add you to the Compiler group. This will help you avoid any setup issues.
If you need further assistance, feel free to contact us via Chat or Phone:
- Chat Support - While on our website, you should see a CHAT bubble in the bottom right-hand corner of the page. Click anywhere on the bubble to begin a chat session.
- Phone Support -
- US: 888-401-4678
- International: +1 801-765-9400
You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.