Launch Week Day 3: Introducing Organization Notifications in Socket.Learn More
Socket
Book a DemoSign in
Socket

@zgxsuerwtmrhjzt/n8n-nodes-python-raw

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zgxsuerwtmrhjzt/n8n-nodes-python-raw

Run Python scripts in n8n with raw output (exitCode, stdout, stderr) - Fork of naskio/n8n-nodes-python

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

n8n-nodes-python-raw

n8n.io - Workflow Automation

Fork of naskio/n8n-nodes-python - Python Function node for n8n with raw script execution and output.

Execute pure Python scripts in n8n and get raw execution results

Key Differences from Original

This fork provides a fundamentally different approach to Python execution in n8n:

Original NodeThis Fork (Raw)
Item-by-item processingSingle script execution
Returns transformed itemsReturns execution metadata
Uses python-fire wrapperDirect Python execution
Hidden stdout/stderrFull stdout/stderr capture
Fire-based argument passingDirect variable injection

Features

Single Execution: Script runs once regardless of input item count
Raw Output: Access to stdout, stderr, and exit codes
Direct Input: All input items available as input_items variable
Environment Variables: Access to custom environment variables
Configurable Python: Choose Python executable path
Execution Metadata: Timestamps, success status, error details

Output Format

The node returns a single item with execution results:

{
  "exitCode": 0,
  "stdout": "Output from print() statements",
  "stderr": "Error messages and warnings",
  "success": true,
  "error": null,
  "inputItemsCount": 3,
  "executedAt": "2024-01-01T12:00:00.000Z"
}

Usage Example

# Available variables:
# - input_items: list of all input data
# - env_vars: dict of environment variables

import json
import sys

# Process input data
print(f"Processing {len(input_items)} items")

results = []
for item in input_items:
    # Your processing logic here
    processed = {"original": item, "processed": True}
    results.append(processed)

# Output results (will appear in stdout)
print(json.dumps(results, indent=2))

# Exit with success
sys.exit(0)

Installation

Using npm

npm install @zgxsuerwtmrhjzt/n8n-nodes-python-raw

Using Docker

Add to your n8n Dockerfile:

RUN cd /usr/local/lib/node_modules/n8n && npm install @zgxsuerwtmrhjzt/n8n-nodes-python-raw

Local Development

See DEVELOPMENT_SETUP.md for development environment setup.

Requirements

  • Python 3.6+ installed and accessible
  • n8n running environment

Node Configuration

Python Code

Write your Python script directly. Available variables:

  • input_items: List of input data from previous nodes
  • env_vars: Dictionary of environment variables

Python Executable

Specify the Python executable:

  • python3 (default)
  • python
  • /usr/bin/python3
  • /path/to/conda/envs/myenv/bin/python

Environment Variables (Optional)

Use the PythonEnvVars credential to provide environment variables to your script.

Use Cases

Data Analysis

import json
import statistics

# Analyze input data
numbers = [item.get('value', 0) for item in input_items]
result = {
    "count": len(numbers),
    "mean": statistics.mean(numbers) if numbers else 0,
    "median": statistics.median(numbers) if numbers else 0
}

print(json.dumps(result))

External API Integration

import requests
import json

# Call external API
response = requests.get("https://api.example.com/data")
if response.status_code == 200:
    print(json.dumps(response.json()))
    sys.exit(0)
else:
    print(f"API call failed: {response.status_code}", file=sys.stderr)
    sys.exit(1)

File Processing

import os
import json

# Process files
processed_files = []
for item in input_items:
    if 'filename' in item:
        if os.path.exists(item['filename']):
            processed_files.append(item['filename'])

result = {"processed_files": processed_files}
print(json.dumps(result))

Original Project Credits

This fork is based on n8n-nodes-python by Mehdi Nassim KHODJA.

License

Apache 2.0 with Commons Clause - see LICENSE.md

Contributing

  • Fork this repository
  • Make your changes
  • Update package.json with your npm username
  • Test your changes
  • Submit a pull request

Support

For issues specific to this fork, please create an issue in this repository. For general n8n questions, refer to the n8n documentation.

Note: This is a fork with significant modifications. For the original item-processing behavior, use the original package.

Keywords

n8n

FAQs

Package last updated on 01 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts