Registry / serialization / ct3
library3.4.0.post5pypypi✓ verified 24d ago

Cheetah3 is a free and open-source template engine and code-generation tool for Python. It is a fork of the original CheetahTemplate library, designed to compile templates into optimized, readable Python code. It blends Python's power and flexibility with a simple template language. The library is actively maintained and supports Python 2.7 and Python 3.4+.

pip install ct3
INSTALL
IMPORT
SIG · CT3
C
ct3
serializationpythonv3.4.0.post5
Install
1.7s avg
Import
190ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.4.0.post5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.200s · 20.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.180s · 21MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Template
from Cheetah.Template import Template

Demonstrates defining a template string, injecting data via a search list, and rendering the output. It also shows using Python imports and `#set` directives within the template.

from Cheetah.Template import Template import datetime # Define a simple template string template_code = """ #set $current_year = datetime.date.today().year Hello, $name! This template was rendered in $current_year using $engine. """ # Create a template instance and pass data t = Template(template_code, searchList=[ {'name': 'Registry User', 'engine': 'Cheetah3'} ]) # Render the template output = str(t) print(output)
cheetah --version
Debug
Known issues
breakingVersion 3.0.0 introduced significant breaking changes, including dropping support for Python versions older than 2.7 and requiring recompilation of all previously compiled Cheetah templates.
fix
Ensure your Python environment meets the minimum requirement (2.7 or >=3.4) and recompile all templates after upgrading to Cheetah3 version 3.0.0 or later.
affects: >=3.0.0
deprecatedThe standalone `cheetah-compile` command-line program is deprecated.
fix
Use `cheetah compile` instead, which provides the same functionality.
affects: All versions >=3.x
gotchaA security issue (arbitrary code execution) was reported. Caution is advised when processing templates from untrusted sources without proper sanitization or sandboxing.
fix
Always treat templates from untrusted sources as potentially malicious. Implement sandboxing or strict input validation if dynamic template loading is necessary.
affects: Potentially all versions prior to specific fixes. Review GitHub issues for updates.
gotchaUnder Python 3, `Cheetah.ImportHooks` now correctly raises `ModuleNotFoundError` instead of `ImportError` when a module cannot be found. Code that specifically catches `ImportError` for missing template modules might need updating.
fix
Update exception handling to catch `ModuleNotFoundError` for module-not-found scenarios, especially when dealing with dynamic template imports.
affects: >=3.4.0
Errors
Common errors & fixes
NameMapper.NotFound: 'variableName'
A placeholder variable used in the Cheetah3 template could not be found in the template's search list.
fix
Ensure the variable is passed into the template's `searchList` or `namespaces` during instantiation, or check for its existence using `$varExists('variableName')` before using it in the template.
SyntaxError: invalid syntax (or similar, often within a generated .py file path)
The Cheetah3 template contains invalid Python syntax or misuse of Cheetah directives, particularly within `<% ... %>` or `<%= ... %>` blocks, or attempts to use unsupported PSP-style tags.
fix
Review the template file for incorrect Python syntax in code blocks or improper use of Cheetah directives. For example, direct Python `break` statements are not allowed in `<% ... %>` blocks that are meant for expressions or simple statements.
UserWarning: You don't have the C version of NameMapper installed!
The C extension for NameMapper, which optimizes variable lookups, was not successfully compiled and installed, causing Cheetah3 to fall back to a slower pure-Python implementation.
fix
Ensure a C compiler (like `gcc` on Linux or appropriate build tools on Windows) is installed and available in your system's PATH. Then, reinstall `ct3` using `pip install --no-binary :none: ct3` to force a source build and attempt to compile the C extensions.
ModuleNotFoundError: No module named 'yourTemplateName'
The Cheetah3 engine cannot find the Python module for a compiled template when attempting to load it, or when one template extends another that is not discoverable in Python's import path.
fix
Compile your `.tmpl` files into `.py` files using `cheetah compile yourTemplate.tmpl` and ensure the directory containing these compiled `.py` files is in `sys.path`. Alternatively, configure Cheetah's `ImportHooks` to allow direct import from `.tmpl` files.
Upgrade
Version history
3.4.0.post5latest on PyPI · released Nov 29, 2025
Audit
Dependencies
PythonrequiredRequired for execution. Supports Python 2.7 and >=3.4.
MarkdownoptionalOptional for Markdown processing within templates.
Agent activity
11 hits · last 30 days
node
10
Resources
ct3 — pip install ct3 · libregistry