How to Set Up a Python Application in cPanel

Knowledgebase / How to Set Up a Python Application in cPanel

How to Set Up a Python Application in cPanel

0 found helpful (0 votes) ...
Back to Knowledgebase

cPanel includes a Setup Python App tool that runs Python web applications using Passenger as the application server. It supports multiple Python versions and installs pip dependencies in an isolated virtual environment per application.


Open Setup Python App

  1. Log in at https://tpc-hosting.com/login and open cPanel.
  2. Under Software, click Setup Python App.
  3. Click Create Application.

Configure the application

  1. Python version: Select the version your application requires (e.g., 3.10, 3.11).
  2. Application root: The directory containing your Python app files (e.g., myflaskapp).
  3. Application URL: The domain or path that will serve the app.
  4. Application startup file: The WSGI entry point (e.g., passenger_wsgi.py). cPanel uses Passenger with WSGI.
  5. Click Create.

WSGI entry point

Your startup file must expose a WSGI-compatible callable named application. Example for a Flask app:

from myapp import app as application

For Django, the passenger_wsgi.py should import and expose the WSGI application from your Django project:

import sys, os
sys.path.insert(0, os.path.dirname(__file__))
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Install pip dependencies

  1. SSH into your account (see: How to Connect to Your Hosting Account via SSH).
  2. Activate the virtual environment created by cPanel:
    source ~/virtualenv/myflaskapp/3.11/bin/activate
  3. Install dependencies:
    pip install -r requirements.txt
  4. Deactivate when done: deactivate

Alternatively, use the pip install modules button in the cPanel Setup Python App interface and enter package names directly.


Restart the application

After updating files or installing packages, restart the app from the Setup Python App list to apply changes.

You can also restart via SSH by touching the restart file:

touch ~/myflaskapp/tmp/restart.txt

Common frameworks supported

  • Flask — lightweight web framework, minimal configuration
  • Django — full-featured framework, requires WSGI setup as shown above
  • FastAPI — async API framework; runs via ASGI but can be wrapped for WSGI use

If your application requires a specific Python package not installable via pip (e.g., a compiled C extension), contact TPC Hosting support — some packages require server-level libraries.


Was this article helpful?



Still need help?

Open a support ticket →

On This Page