Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). Varbase Media Header 9.2.1 Minor update available for module varbase_media_header (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

Python Environment

14 sites No security coverage
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.

Activity

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

Releases

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