Skip to content
MAMP PRO Documentation

Python

MAMP PRO - Sites - Site - Python

  • Enable Python
    Enable this option if you want to use Python for the selected site.

    This option can only be enabled if you have selected Apache as the web server for the site and enabled the “wsgi_module” module (Settings › Server › Apache).

  • App name
    The app name assigns a URL to a specific target directory. For example, if you use the value “site-1-app” here, your Python project (the app index.py file) can be accessed in the browser via the URL “https://site-1:8890/site-1-app” (may differ depending on your site name, SSL and port settings).

    • Open
      To open your site in your default browser, click on the “Open” button to the right of the site name field. This button is only active when the servers are running.

    • Open in The “Open in” button allows you to open the site’s website in a specific browser. This button is only active when the servers are running.

  • Process Group
    Enter the name of the desired process group here. You can combine several Python apps in a process group. When you activate the “Enable Python” option, MAMP PRO creates a separate process group for each of your Python apps.

  • App index.py File
    In web applications, the “index.py” file serves as the main file/initialization script that starts the application code and executes certain tasks, such as setting up a database connection or loading configurations.

    • Choose…
      Here you can choose the directory and the file name. By default, this file is located at “DOCUMENT_ROOT/index.py”.

    • Edit…
      Click this button to open the selected file in the MAMP PRO editor.

    • Open in
      Click this button to open the selected file in a program of your choice (e.g. a text editor).

  • Advanced Options

    • Virtual Env Path
      Here you specify the path to a virtual environment to be used for the selected site. A virtual environment is an isolated Python environment that allows you to manage project-specific dependencies separately from other projects and the global Python interpreter.

      • New…
        Click this button to create a virtual environment and assign it to the site.

        You can define the name (corresponding to the directory name) and specify whether installed third-party packages (site-packages) should be included from the MAMP PRO Python installation. If these two options are not visible, you can show them by clicking the “Options” button.

        MAMP PRO - Sites - Site - Python - create virtual environment

      • Choose…
        Click this button to select a virtual environment.

      • Unset
        Click this button to clear the “Virtual Env Path” selection. The virtual environment itself remains unchanged.

  • Directive <Directory> in httpd.conf
    Here you can directly edit the Python configuration, which is written to the Apache configuration file “httpd.conf”.

    • Edit…
      Click this button to open the Python configuration template for editing. You can use the following placeholders in this template:

      • MAMP_PythonAppName_MAMP ← field “App Name”
      • MAMP_PythonProcessGroup_MAMP ← field “Process Group”
      • MAMP_PythonAppAlias_MAMP ← field “App Name”
      • MAMP_PythonIndexPyPath_MAMP ← field “App index.py File”
      • MAMP_VirtualHost_DocumentRoot_MAMP ← field “Document root”
      • MAMP_VirtualHost_Port_MAMP ← field “Port number”

      MAMP PRO - Sites - Site - Python - Directive Directory in httpd.conf - Edit

    • View…
      Click this button to view the Python configuration. The placeholders have been replaced by the real values.

      MAMP PRO - Sites - Site - Python - Directive Directory in httpd.conf - View

    • Reset…
      Click this button to reset the Python configuration template.

      MAMP PRO - Sites - Site - Python - Directive Directory in httpd.conf - Reset