Set Up a Python Application in cPanel
How to create, configure, and manage a Python application in cPanel using Setup Python App (Application Manager), including the virtual environment, dependencies, and startup file.
cPanel can run Python web applications (Flask, Django, FastAPI, and others) through its Setup Python App tool, which uses Passenger to serve your app and gives each app its own isolated virtual environment. This guide walks through creating an application and getting it running.
Create the application
apps/myapp.example.com or example.com/api.passenger_wsgi.py) and the Application Entry point (the callable inside it, commonly application).cPanel creates the application and a dedicated virtual environment for it. The page then shows a command you can copy to enter that environment from the terminal (it looks like source /home/USER/virtualenv/apps/myapp/3.x/bin/activate).
Install your dependencies
Your app’s packages must be installed into the application’s virtual environment, not the system Python.
The simplest way is a requirements.txt file:
requirements.txt file in your application root listing your packages.requirements.txt and click Run Pip Install.Prefer the command line? Activate the environment first using the source command shown on the app’s page, then install normally:
source /home/USER/virtualenv/apps/myapp/3.x/bin/activate
pip install -r requirements.txt
pip or python without activating the application's virtual environment, packages land in the wrong place and your app will report missing modules. Always run the source ...activate command shown on the application's page before installing or testing.
The startup file (Passenger)
Passenger loads the callable named in your Entry point from your startup file. For a WSGI app the file is usually passenger_wsgi.py. A minimal example that imports a Flask app defined in app.py:
from app import app as application
For Django, point Passenger at your project’s WSGI application instead:
from myproject.wsgi import application
Apply changes and restart
Whenever you change code, dependencies, or environment variables, restart the app so Passenger reloads it:
touch /home/USER/apps/myapp/tmp/restart.txt.Troubleshooting
The page shows a 500 / “We’re sorry” error Check your application’s log. Passenger reports startup errors (a bad import, a missing package, a wrong entry point) when it tries to load the startup file. Confirm the entry point name matches the callable in your startup file.
“ModuleNotFoundError” for a package you installed
The package was installed outside the app’s virtual environment. Activate the environment with the source command from the app’s page and reinstall, then restart the app.
Static files or a sub-path don’t load
Confirm the Application URL matches where you are requesting the app, and that any framework-level static handling (Django collectstatic, for example) has been run.