Description
Changelog
Reviews (0)

py4godot: Python Scripting for Godot

py4godot is a GDExtension plugin that lets you write Godot scripts in Python. You can define classes, exported properties, and signals, and implement the standard lifecycle methods (_ready, _process, and so on) much like you would in GDScript, while having Python's standard library and PyPI ecosystem available to your code.

What It Does

  • Adds Python as a script language inside Godot 4.
  • Provides a @gdclass decorator so a Python class can subclass any Godot class (Node, Node3D, Control, Resource, …) and be attached to nodes in your scenes.
  • Supports exported properties via standard Python type annotations; they show up in the inspector.
  • Supports signals with typed arguments, declared in Python.
  • Provides bindings to the Godot API, including core types like Vector3, Transform3D, Color, Array, and Dictionary.

Example

The class name under @gdclass must match the filename.

# file: node3d.py
from py4godot.methods import private
from py4godot.signals import signal, SignalArg
from py4godot.classes import gdclass
from py4godot.classes.core import Vector3
from py4godot.classes.Node3D import Node3D

@gdclass
class node3d(Node3D):
    test_int: int = 5
    test_float: float = 5.2
    test_vector: Vector3 = Vector3.new3(1, 2, 3)
    test_signal = signal([SignalArg("test_arg", int)])

    def _ready(self) -> None:
        pass

    def _process(self, delta: float) -> None:
        pass

    @private
    def helper_method(self):
        pass

For more examples, look here: https://github.com/niklas2902/py4godot-examples

Possible Use Cases

Some things you could use Python-in-Godot setups for:

  • Calling NumPy, pandas, or other scientific libraries from gameplay code.
  • Loading trained ML models (PyTorch, scikit-learn, …) to drive NPC behavior or procedural generation.
  • Reusing existing Python tooling (parsers, importers, data pipelines) inside a Godot project.

Installation

After downloading, you need to restart the editor for the plugin to be properly registered. There is no plugin to enable in Project Settings; the GDExtension is picked up automatically. When creating a new script, you can select Python as the language.

Requirements

  • Godot 4.x (latest 4.x recommended).

Supported Platforms

  • Windows 64-bit
  • Linux 64-bit
  • macOS arm64

Windows/Linux 32-bit, Android, and iOS are not currently supported.

Project Status

py4godot is under active development. The core workflow (@gdclass, properties, signals, lifecycle methods, and bindings to the Godot API) is functional and tracks Godot 4.x releases, but the API surface is still expanding and you may run into rough edges on less common classes or workflows. It's well suited to prototypes, jam projects, tooling, and small-to-mid projects; for large production work, evaluate carefully and consider mixing with GDScript.

Bug reports and contributions are welcome on GitHub.

Links

  • Repository: https://github.com/niklas2902/py4godot
  • Examples: https://github.com/niklas2902/py4godot-examples
  • Developer Guide: https://github.com/niklas2902/py4godot/wiki/Developer-Guide

Related Projects

py4godot was inspired by godot-python. Other Python-for-Godot projects worth looking at:

  • godot-python: https://github.com/touilleMan/godot-python
  • godot-python-extension: https://github.com/maiself/godot-python-extension

License

MIT

Changelog for version 4.7-alpha19

No changelog provided for this version.

Reviews

Python for Godot has no reviews yet.

Login to write a review.