๐ŸŸข Network Status| First month from $2.00 โ€” fully managed | Contact Support
Skip to content
Need help? Real engineers available 24/7. Average response under 15 minutes. Open a support ticket โ†’

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 โ€‹

  1. In cPanel, go to Software โ†’ Setup Python App.
  2. Click Create Application.
  3. Choose the Python version you need from the dropdown.
  4. Set the Application root: the folder (relative to your home directory) where your code lives, for example apps/myapp.
  5. Set the Application URL: the domain or subdomain/path where the app should be reachable, for example example.com or example.com/api.
  6. Set the Application startup file (for example passenger_wsgi.py) and the Application Entry point (the callable inside it, commonly application).
  7. 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:

  1. Place a requirements.txt file in your application root listing your packages.
  2. Back in Setup Python App, open the application and find the Configuration files field. Add 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:

bash
source /home/USER/virtualenv/apps/myapp/3.x/bin/activate
pip install -r requirements.txt
โœ“
Always activate the virtualenv first
If you run 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:

python
from app import app as application

For Django, point Passenger at your project's WSGI application instead:

python
from myproject.wsgi import application

Apply changes and restart โ€‹

Whenever you change code, dependencies, or environment variables, restart the app so Passenger reloads it:

  1. Open the application in Setup Python App and click Restart.
  2. 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.

โ„น
If Setup Python App will not open
If the Setup Python App interface itself errors or won't load (rather than your application), that is usually a server-side issue. Open a support ticket and we will check it.

Next steps โ€‹

Managed hosting that actually manages.