Using the Python Selector in cPanel

This article describes how to use the Python Selector in cPanel to create a Python application that uses a specific Python version. Additionally, you can use a virtual environment to develop the application further.

Tabla de contenido

Using the Python Selector

To create a new Python application that uses a specific Python version, follow these steps:

  1. Log in to cPanel.
    If you do not know how to log in to your cPanel account, please see this article.
  2. In the SOFTWARE section of the cPanel home screen, click Setup Python App:

    cPanel - Software - Setup Python App icon

  3. Click CREATE APPLICATION:

    cPanel - Python Selector - Create Application button

    The application form appears:

    cPanel - Python - Create application form

  4. In the Python version list box, select the Python version you want to use.
  5. In the Application root text box, type the directory where the application files are located.
  6. In the Application URL list box, select the domain, and then type a URL for the application.
  7. In the Application startup file text box, you can optionally specify the startup file for the application.

    If you do not specify a startup file, cPanel creates a passenger_wsgi.py startup file for you.
  8. In the Application Entry point text box, you can optionally specify the callable object for the application. 

    If you do not specify the application entry point, cPanel creates a default application object for you.
  9. In the Passenger log file text box, you can optionally specify a log file for the application.
  10. Under Environment variables, you can optionally set environment variables for the application. To do this, click ADD VARIABLE, type the variable name and value, and then click DONE.
  11. In the top right corner of the page, click CREATE:

    cPanel - Python Selector - Create button

    cPanel creates the application and sets up the Python environment.

  12. To work inside the newly created environment, connect to your account using SSH, and then type the following command. Replace username, application, and version with the actual values as shown at the top of the page, next to Enter to the virtual environment. To enter to virtual environment, run the command:

    source /home/username/virtualenv/application/version/bin/activate && cd /home/username/application
    

    You can now install modules or use other commands to develop the Python application further. Additionally, you can control the application's running state from cPanel:

    • To stop the application, click STOP APP.
    • To restart the application, click RESTART.
    • To completely remove the application from cPanel, click DESTROY.

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.