Set Up a Python Application in cPanel โ
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 โ
- In cPanel, go to Software โ Setup Python App.
- Click Create Application.
- Choose the Python version you need from the dropdown.
- Set the Application root: the folder (relative to your home directory) where your code lives, for example
apps/myapp. - Set the Application URL: the domain or subdomain/path where the app should be reachable, for example
example.comorexample.com/api. - Set the Application startup file (for example
passenger_wsgi.py) and the Application Entry point (the callable inside it, commonlyapplication). - Click Create.
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:
- Place a
requirements.txtfile in your application root listing your packages. - Back in Setup Python App, open the application and find the Configuration files field. Add
requirements.txtand 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.txtpip 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 applicationFor Django, point Passenger at your project's WSGI application instead:
from myproject.wsgi import applicationApply changes and restart โ
Whenever you change code, dependencies, or environment variables, restart the app so Passenger reloads it:
- Open the application in Setup Python App and click Restart.
- Or, from the terminal, touch the restart file:
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.

