Short answer: Open Setup Python App in cPanel, click 'Create Application', select Python version, establish project directory path, and leverage isolated virtual environment.
Deploy Python web applications, configure virtual environments, and run Django or Flask apps using CloudLinux Python Selector and WSGI.
Before you start: Back up your site files and database and download the backup to your own computer. How to take a full backup
Quick reference
| Tool Location | cPanel > Software > Setup Python App |
|---|---|
| Supported Python Versions | Every version listed in Setup Python App |
| WSGI Handler | passenger_wsgi.py |
| Virtualenv | Automatically provisioned per application |
Steps
- Create Application in cPanel:
- Navigate to Software > Setup Python App.
- Click Create Application.
- Python Version: Choose the newest version your project supports.
- Application Root: Path to project directory (e.g.,
python-app). - Application URL: Domain or subdomain for the app.
- Application Startup File:
passenger_wsgi.py. - Click Create.
- Activate Virtualenv in Terminal:
- cPanel displays a command at the top: "Command for entering to the virtual environment".
- Copy it (e.g.
source /home/user/virtualenv/python-app/3.11/bin/activate). - Open Terminal in cPanel and paste that command.
- Install Packages: In the active virtualenv terminal, run:
pip install -r requirements.txt - Configure passenger_wsgi.py & Restart: Ensure
passenger_wsgi.pyexportsapplication(e.g.from myproject.wsgi import applicationfor Django). Click Restart in cPanel.
Troubleshooting and tips
- ImportError in WSGI: Ensure that your project directory is added to
sys.pathinsidepassenger_wsgi.py:import sys, os sys.path.insert(0, os.path.dirname(__file__))
Need more help? If you run into an error while following these steps, open a ticket with technical support and our team will look into it. Open a ticket