ComfyUI > Nodes > python-interpreter-node > Python Interpreter

ComfyUI Node: Python Interpreter

Class Name

Exec Python Code Script

Category
DevTools
Author
christian-byrne (Account age: 1989days)
Extension
python-interpreter-node
Latest Updated
2026-03-11
Github Stars
0.08K

How to Install python-interpreter-node

Install this extension via the ComfyUI Manager by searching for python-interpreter-node
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter python-interpreter-node in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Python Interpreter Description

Executes custom Python code in a node-based environment for flexible data manipulation.

Python Interpreter:

The Exec Python Code Script node is a versatile tool designed to execute custom Python code within a node-based environment. This node is particularly beneficial for developers and AI artists who wish to integrate custom logic or processing steps into their workflows without leaving the node interface. By allowing the execution of Python scripts, it provides a high degree of flexibility and customization, enabling users to manipulate data, perform calculations, or apply specific algorithms directly within their projects. The primary goal of this node is to enhance the creative and functional capabilities of the node-based system by offering a programmable interface that can interact with various data types and structures.

Python Interpreter Input Parameters:

raw_code

This parameter accepts a string containing the Python code you wish to execute. It serves as the core of the node's functionality, allowing you to define the operations or transformations you want to perform. There are no strict minimum or maximum values, but the code should be syntactically correct Python. The default value is an empty string.

image1

This parameter is an optional tensor representing an image, initialized by default to a random 32x32 RGB image. It can be used within your script to perform image processing tasks or as input data for custom algorithms.

image2

Similar to image1, this parameter is another optional tensor for an image, also defaulting to a random 32x32 RGB image. It allows for operations involving multiple images, such as blending or comparison.

mask1

This parameter is an optional tensor representing a mask, defaulting to a random 32x32 tensor. Masks are typically used to specify areas of interest or to apply selective operations on images.

mask2

Another optional tensor for a mask, similar to mask1, with the same default random 32x32 tensor. It provides additional flexibility for operations requiring multiple masks.

number1

This parameter is an optional float, defaulting to 0.0. It can be used for numerical calculations or as a parameter within your script.

number2

An optional integer parameter, defaulting to 0. It serves a similar purpose to number1, allowing for integer-specific operations or logic.

text1

This parameter is an optional string, defaulting to "hello". It can be used for text processing or as a message within your script.

text2

Another optional string parameter, defaulting to "world". It complements text1 for operations involving multiple text inputs.

list1

This parameter is an optional list, defaulting to [1]. It can be used to pass a collection of items or data points to your script.

dict1

An optional dictionary parameter, defaulting to {"key": 1}. It allows for structured data input, useful for more complex operations or configurations.

any1, any2, any3, any4

These parameters are optional and can hold any data type, defaulting to random 32x32 RGB tensors. They provide additional flexibility for passing various data types or custom objects to your script.

verbose

A boolean parameter that controls the verbosity of the script execution, defaulting to True. When enabled, it may provide additional output or logging information.

output_text

An optional string parameter for capturing or defining output text from your script. The default is an empty string.

unique_id

An optional parameter for specifying a unique identifier, useful for tracking or managing script executions. It defaults to None.

extra_pnginfo

An optional parameter for additional PNG metadata, defaulting to None. It can be used to store or retrieve extra information related to image processing tasks.

Python Interpreter Output Parameters:

image1

This output returns the processed or modified image tensor from your script, if applicable.

image2

Similar to image1, this output provides another image tensor result from your script.

mask1

This output returns the processed or modified mask tensor, if your script involves mask operations.

mask2

Another mask tensor output, similar to mask1, reflecting any changes made by your script.

number1

This output returns a float result from your script, useful for numerical calculations or metrics.

number2

An integer result from your script, similar to number1, for integer-specific outputs.

text1

This output provides a string result from your script, useful for text processing or messages.

text2

Another string output, complementing text1, for additional text results.

list1

This output returns a list result from your script, useful for collections or data series.

dict1

A dictionary result from your script, reflecting any structured data outputs or configurations.

any1, any2, any3, any4

These outputs can hold any data type, reflecting the results of your script's operations on the corresponding input parameters.

Python Interpreter Usage Tips:

  • Ensure your Python code is syntactically correct and tested in a standalone environment before using it in the node to avoid execution errors.
  • Utilize the verbose parameter to get more detailed output or logging information, which can be helpful for debugging or understanding the script's behavior.
  • Leverage the flexibility of any1, any2, any3, and any4 to pass custom objects or data structures that your script may require.

Python Interpreter Common Errors and Solutions:

SyntaxError

  • Explanation: This error occurs when there is a syntax mistake in your Python code.
  • Solution: Review your code for syntax errors, such as missing colons, unmatched parentheses, or incorrect indentation, and correct them.

NameError

  • Explanation: This error happens when your code references a variable or function that has not been defined.
  • Solution: Ensure all variables and functions used in your code are properly defined and spelled correctly.

TypeError

  • Explanation: This error arises when an operation or function is applied to an object of inappropriate type.
  • Solution: Check the data types of your variables and ensure they are compatible with the operations or functions being used.

ValueError

  • Explanation: This error occurs when a function receives an argument of the right type but inappropriate value.
  • Solution: Verify that the values passed to functions or operations are within the expected range or format.

Python Interpreter Related Nodes

Go back to the extension to check out more related nodes.
python-interpreter-node
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.