PyTinyTeX
The easiest way to go from .tex to .pdf in Python. PyTinyTeX wraps TinyTeX — a lightweight, cross-platform, portable LaTeX distribution based on TeX Live — and gives you compilation, package management, and diagnostics from Python or the command line.
import pytinytex
pytinytex.download_tinytex()
result = pytinytex.compile("paper.tex", auto_install=True)
print(result.pdf_path) # paper.pdf
No system-wide TeX installation required. Missing packages are installed automatically.
Installation
pip install pytinytex
Python 3.8+ on Linux, macOS, and Windows.
Quick start
1. Get TinyTeX
import pytinytex
# Download the default variation (variation 1: ~90 common LaTeX packages)
pytinytex.download_tinytex()
# Or pick a variation:
# 0 — infrastructure only, no packages
# 1 — common packages (default)
# 2 — extended package set
pytinytex.download_tinytex(variation=2)
# Track download progress
pytinytex.download_tinytex(progress_callback=lambda downloaded, total: print(f"{downloaded}/{total} bytes"))
2. Compile a document
result = pytinytex.compile("paper.tex")
if result.success:
print("PDF at:", result.pdf_path)
else:
for error in result.errors:
print(f" ! {error.message} (line {error.line})")
Multi-pass compilation for cross-references and TOC:
result = pytinytex.compile("paper.tex", num_runs=2)
Choose your engine:
result = pytinytex.compile("paper.tex", engine="xelatex")
result = pytinytex.compile("paper.tex", engine="lualatex")
3. Auto-install missing packages
The killer feature: if your document needs a package you don't have, PyTinyTeX can find it, install it, and retry — all in one call:
result = pytinytex.compile("paper.tex", auto_install=True)
print(result.installed_packages) # e.g. ['booktabs', 'pgf']
Package management
Full access to the TeX Live package manager (tlmgr):
import pytinytex
pytinytex.install("booktabs")
pytinytex.remove("booktabs")
# List installed packages (returns list of dicts)
for pkg in pytinytex.list_installed():
print(pkg["name"])
# Search for packages
pytinytex.search("amsmath")
# Detailed package info (returns dict)
pytinytex.info("booktabs")
# Update all packages
pytinytex.update()
# TeX Live version
pytinytex.get_version()
Engine discovery
Locate LaTeX engine executables (variation 1+):
pytinytex.get_engine("pdflatex") # full path to the executable
pytinytex.get_engine("xelatex")
pytinytex.get_engine("lualatex")
# Convenience shortcuts
pytinytex.get_pdflatex_engine()
pytinytex.get_xelatex_engine()
pytinytex.get_lualatex_engine()
LaTeX log parser
Parse any LaTeX .log file into structured data — useful even outside PyTinyTeX:
from pytinytex import parse_log
with open("paper.log") as f:
parsed = parse_log(f.read())
for error in parsed.errors:
print(f"{error.file}:{error.line}: {error.message}")
for warning in parsed.warnings:
print(warning.message)
# Missing .sty packages detected automatically
print(parsed.missing_packages) # e.g. ['tikz', 'booktabs']
Health check
Diagnose your TinyTeX installation:
result = pytinytex.doctor()
for check in result.checks:
status = "PASS" if check.passed else "FAIL"
print(f" [{status}] {check.name}: {check.message}")
Checks: TinyTeX installed, PATH configured, tlmgr functional, engine availability.
Command-line interface
Every feature is also available from the terminal:
# Download TinyTeX
pytinytex download
pytinytex download --variation 2
# Compile a document
pytinytex compile paper.tex
pytinytex compile paper.tex --engine xelatex --runs 2 --auto-install
# Package management
pytinytex install booktabs
pytinytex remove booktabs
pytinytex list
pytinytex search amsmath
pytinytex info booktabs
pytinytex update
# Diagnostics
pytinytex doctor
pytinytex version
# Also works as a Python module
python -m pytinytex doctor
Integrating with pypandoc
PyTinyTeX pairs naturally with pypandoc for converting Markdown, HTML, and other formats to PDF:
import pytinytex
import pypandoc
pdflatex_path = pytinytex.get_pdflatex_engine()
pypandoc.convert_file("input.md", "pdf", outputfile="output.pdf",
extra_args=["--pdf-engine", pdflatex_path])
Uninstalling TinyTeX
pytinytex.uninstall() # removes the TinyTeX directory
Or from the CLI:
pytinytex uninstall
Contributing
Contributions are welcome. When opening a PR, please keep the following guidelines in mind:
- Before implementing, please open an issue for discussion.
- Make sure you have tests for the new logic.
- Add yourself to contributors in this README unless you are already there.
Contributors
- Jessica Tegner — Maintainer and original creator of PyTinyTeX
License
PyTinyTeX is available under the MIT license. See LICENSE for more details. TinyTeX itself is available under the GPL-2 license.
Metadata
Release files for PyTinyTeX 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytinytex-0.5.1.tar.gz | 33.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytinytex-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 53.9 kB
Release files / pytinytex-0.5.1.tar.gz
| Download URL | pytinytex-0.5.1.tar.gz |
|---|---|
| Size | 33.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
206d2adcbe58262ee501399c7aed30b684473b03dcb71fc248271d1801138525
|
|
BLAKE2b-256 checksum How to use checksums |
7c9cdfbe60d3f33b3406fb9a50d06d9f1ad086e24d1bc83d6fdd992e12d02eb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 13, 2026.
Transparency logRelease files / pytinytex-0.5.1-py3-none-any.whl
| Download URL | pytinytex-0.5.1-py3-none-any.whl |
|---|---|
| Size | 20.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
16cbad3f70e40a14855bbd807bab9ba74232e87268738dc4ce2af4f6abd6d248
|
|
BLAKE2b-256 checksum How to use checksums |
76ae169877f749443356ac9f5ff07dc128fdead4ccd4094ba3ad9bc5ee53d2a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 13, 2026.
Transparency log