How to use 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.

Table of Contents

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. Open the Python App tool:
    • If you are using the Jupiter theme, on the Tools page, in the Software section, click Setup Python App:

      cPanel - Software - Setup Python App icon

    • If you are using the Paper Lantern theme, in the SOFTWARE section of the cPanel home page, 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.

    • This option is only available on cPanel version 110 and earlier. For information about how to determine the cPanel version running on your account, please see this article.
    • Logging is not supported on servers running LiteSpeed.
  10. In the Configuration files section, you can manage and install modules for the application:

    • In the Add another file and press enter text box, type the name of the configuration file for your application and then press Enter. Typically, this file is named requirements.txt.
      For detailed information about the requirements.txt file format, please visit https://pip.pypa.io/en/latest/reference/requirements-file-format/.
    • Click Add.
    • Click Run Pip Install, and then click the name of the configuration file you specified. The Python Selector installs the specified modules for the application.
  11. 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.
  12. 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.

  13. 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.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.