Skip to main content

Do you support Python?

Limits about the native python included with cPanel

Short answer, yes our servers support it.

The Python version that cPanel includes natively is the one used for running application at the user accounts.

When this article was published, the version of Python at our server is Python 3.6.8. We can't downgrade or upgrade this version.

Even when Python is part of our features and the programming languages/platforms supported by cPanel, we don't provide any kind of technical support about it. StableHost does not develop, or ship any kind of Python applications and we don't have specialized agents about the same.

We have taken part of a cPanel article that will guide you through the steps in how to setup and run your Python application from your web hosting account.

If you are running a web hosting account, the SSH add-on is required so you can run the commands.



Install the application

  1. Log in to the server via SSH as a cPanel user.

  2. Create the application’s directory, relative to your home directory. To do this, run the following command, where directoryname represents the application’s directory:

    mkdir directoryname

  3. Change to the application’s directory. To do this, run the following command, where directoryname represents the application’s directory:

    cd directoryname

  4. Copy the application to your server.

  5. Create the passenger_wsgi.py file. In this example, pythonapp represents your Python application and MyApprepresents an application function:

    echo "from pythonapp import MyApp as application" > passenger_wsgi.py

  6. Install the application’s dependencies. To do this, create a requirements.txt file for pip, then run the following command:

    pip install –user -r requirements.txt


Notes:

You can also install any dependencies in the Ensure Dependencies section of cPanel’s Application Manager interface (cPanel » Home » Software » Application Manager).

Your dependency version requirements must match your Python version. For example, a dependency that requires Python 2 or earlier will not work on an application that you run with Python 3.

Some dependencies will change what your application requires to work. For example, Flask’s render_templatedependency requires that you keep your index.html file in a templates folder.

Test the application

  1. Run the following command:

    python pythonapp.py


    The output might resemble the following example:

    <!DOCTYPE html> … <section class="main"> <h1>Hello world!</h1> Welcome to the example app. </section> </body> </html>

  2. Open another terminal window and log in to the server via SSH as the same cPanel user.

  3. Run the following command:

    curl http://localhost:5000


    The output will resemble the following example:

    Hello, World!

Register the application

After you install the application, register it. To do this, use cPanel’s Application Manager interface (cPanel » Home » Software » Application Manager).

You can then access the application in a web browser with the following URL:

Restart the application

To restart your application after you edit it, create the restart.txt touch file. Create this file in the application’s /tmp directory. This file directs Phusion Passenger® to restart the application after you modify it. This action applies your changes to the application.


Did this answer your question?