Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Python Environment

3 sites No security coverage Drupal 11 · not 10
View on drupal.org

This module allows you to run Python scripts directly from your Drupal site. It automatically creates a `/python/` directory for your scripts and uses a service to execute them, accepting and returning data in JSON format for easy integration.

Introduction

The Python Environment module allows you to seamlessly integrate Python scripts into your Drupal project. It provides a service that runs Python scripts from Drupal, making it easy to leverage Python for various tasks like data processing, automation, and custom logic.

Features

  • Run Python scripts directly from Drupal: Execute Python code from your Drupal site using a simple service.
  • Automatic Python script folder creation: The /python/ folder is automatically created at the root of your project, where you can place your Python scripts.
  • JSON-based input and output: Python scripts accept and return data in JSON format, making it easy to integrate with Drupal.
  • Separation of concerns: Python and Drupal logic remain separate, allowing clean code management while utilizing both platforms.
  • Ideal for custom workflows: Perfect for integrating machine learning models, API interactions, or advanced data processing using Python.

Post-Installation

Once you install and enable the python_env module:

  • The module automatically creates a /python/ directory at the root of your Drupal project if it doesn't already exist.
  • You can start adding your Python scripts to this directory.
  • To run a Python script, simply call the python_env.bridge service in your PHP code and provide the script name along with arguments.

No further configuration is required. You just need to place your Python scripts in the /python/ directory and use the service to execute them.

Additional Requirements

  • Drupal 11+
  • Python 3 installed on your server and accessible via the python3 command.
  • Symfony Process Component, which is included by default in Drupal Core.

No additional modules or libraries are required for the core functionality of this module. However, you may want to integrate Python libraries based on your use case.

Similar projects

There are other modules for executing custom scripts or managing external integrations, but Python Environment is unique in how it integrates Python directly into Drupal, offering clean service-based architecture with structured input and output.

Supporting this Module

If you’d like to support this module, please consider contributing to the issue queue on Drupal.org or providing financial support for further development through platforms like GitHub Sponsors.

Community Documentation

For more information, please refer to the documentation and the module page on Drupal.org. Additional resources, such as video tutorials or demo sites, may be added in the future.

Depends on

Dependencies of the latest stable release

  • system Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Apr 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

Version Type Core Release date
1.0.1 Stable 11 Apr 21, 2025
1.0.0 Stable 11 Apr 21, 2025