Python Environment¶
Explains the features and limitations of Cinema 4D’s Python runtime.
Cinema 4D 2027.0.0 embeds a CPython 3.11 interpreter. It behaves much like standard Python, but code runs in
Cinema 4D alongside other scripts and plugins. The application supplies the c4d, maxon, and mxutils modules.
The differences below matter when importing libraries and managing interpreter state.
Virtual Machine¶
The embedded interpreter persists while Cinema 4D runs. Scripts and plugins share its imported modules and other interpreter-wide state. Reloading a script does not necessarily reset a module that it previously imported; restarting Cinema 4D provides a fresh interpreter.
Difference |
Implication |
|---|---|
Shared state |
Changes to common modules and global settings can affect other scripts and plugins in the same application process. |
Execution context |
Script Manager provides |
Search paths |
A plugin folder is not automatically on |
Standalone Python |
Cinema 4D ships |
Libraries and Search Paths¶
Third-party packages must be compatible with Cinema 4D’s Python version, platform, and architecture. An editor’s virtual
environment is separate from the application: installing a package there does not install it into Cinema 4D. Native
extensions need matching binaries; check the Python Console with import sys; print(sys.version) when selecting them.
Install libraries in an application-specific or interpreter-bound search path, or configure the appropriate
C4DPYTHONPATH variable for the Python version shipped with your Cinema 4D release. Avoid putting unrelated versions
of the same library on global search paths. Plugin directories are not default module search paths; use
mxutils.LocalImportPath for local imports rather than permanently changing sys.path. See
External Libraries for the current paths, variable names, and examples.
Interpreter Limits¶
Do not launch another Cinema 4D Python VM with multiprocessing or by passing sys.executable to subprocess.
Use Standalone Interpreter for supported standalone execution. Do not use Python’s threading module to
operate on Cinema 4D data; see Scene Execution and c4d.threading for the application’s
threading rules. Scene execution callbacks can be invoked repeatedly or concurrently and must not make arbitrary edits
to the active document.