PrusaSlicer-Py
PrusaSlicer-Py is a Python toolkit for automating and extending PrusaSlicer functionality through its command-line interface (CLI). This project aims to simplify slicing workflows, customize G-code generation, and provide a flexible framework for integrating PrusaSlicer into Python-based workflows.
Features
- Automate slicing operations using the PrusaSlicer CLI.
- Customize slicing parameters dynamically.
- Load and manage shapes from
.stlfiles or existing profiles from.3MFor.AMFfiles. - Support for generating G-code with fine-tuned settings for FFF and SLA printers.
Status
Pre-1.0. The API may change; what it establishes will not be overstated.
The full path -- discovery, check_version, generate_help,
get_example_shapes, and a real end-to-end slice_model -- is exercised
against a real PrusaSlicer on every supported install mode, in CI:
| platform | install mode | engine |
|---|---|---|
| Linux | Flathub Flatpak | 2.9.6 |
| Linux | distro package on PATH |
packaged build |
| macOS | Homebrew cask (.app bundle) |
latest cask |
| Windows | official portable .zip on PATH |
2.9.6 |
Those jobs set PRUSASLICER_PY_REQUIRE_ENGINE=1, so a runner that fails to
install the engine fails the job rather than quietly skipping. The CI
workflow separately runs the mocked suite on Linux 3.11/3.12/3.13 and Windows
with no engine present, where the engine tests skip and the log says how many
were withheld (docs/DECISIONS.md D3).
Not covered: SLA workflows beyond --help-sla parsing, and any printer profile
handling beyond passing arguments through.
Finding the engine
PrusaSlicer is located in this order:
- an explicit
slicer_pathyou pass in, prusa-slicer(orprusa-slicer-console.exe) onPATH,- a Flathub Flatpak (
com.prusa3d.PrusaSlicer).
PrusaSlicer().engine_kind tells you which was found. Flatpak support is not
cosmetic: a Flatpak has no binary on PATH, so discovery that only asks PATH
reports "not installed" on the most common Linux install (D9).
Getting Started
Prerequisites
-
PrusaSlicer Installation:
- Download and install PrusaSlicer.
- Ensure
prusa-slicer-console.exe(Windows) or the equivalentprusa-slicerCLI executable is installed. - Add the directory containing the executable to your system's
PATHenvironment variable (or the equivalent for your operating system).- On Windows, this is the folder containing
prusa-slicer-console.exe. - On Linux, macOS, and other Unix-like systems, this is the folder containing
prusa-slicer.
- On Windows, this is the folder containing
-
Python Setup:
Installation
-
Clone the repository:
git clone https://github.com/heibench/prusaslicer-py.git cd prusaslicer-py
-
Install it:
pip install -e .
Or, for development:
just setup # uv sync --locked just lock # re-resolve uv.lock after a dependency change just check # fmt-check + lint + typecheck just test # run the suite
The package itself has no runtime dependencies.
Usage
from prusaslicer_py import PrusaSlicer, SliceError
slicer = PrusaSlicer() # found on PATH, or as a Flathub Flatpak
print(slicer.engine_kind) # "path" or "flatpak"
print(slicer.check_version()) # PrusaSlicer-2.9.6+flathub.org based on Slic3r ...
# PrusaSlicer ships example models; pick one to slice.
torus = next(s for s in slicer.get_example_shapes() if s.endswith("torus.stl"))
try:
result = slicer.slice_model(torus, "torus.gcode")
except SliceError as e:
# Either the engine failed, or it exited 0 without producing the file --
# a mistyped destination, an option that no-ops, an empty plate. Both
# carry output_path, returncode, stdout and stderr as attributes.
print(f"no G-code produced: {e}\n{e.stderr}")
else:
print(f"{result.output_path} ({result.size_bytes} bytes, exit {result.returncode})")
slice_model returns only once it has checked that the file exists and is not
empty. "The call did not raise" and "the artifact was produced" are not the
same claim, and this package will not conflate them.
Pass slicer_path= to point at a specific executable instead of searching:
slicer = PrusaSlicer(slicer_path="/opt/PrusaSlicer/bin/prusa-slicer")
NOTE:
- Replace slicer_path with the path to your PrusaSlicer CLI executable, if not in PATH.
- Provide the .stl file, desired output path for the .gcode, and any additional parameters as keyword arguments.
slice_modelreturns aSliceResult(output_path,size_bytes,returncode,stdout,stderr). It returns only once it has confirmed the G-code exists and is non-empty. "It did not raise" is a checked guarantee, not an assumption.- Both failures raise a
SliceError(aRuntimeError) carrying those same fields:SliceEngineErrorwhen PrusaSlicer exits non-zero,SliceOutputErrorwhen it exits 0 without producing the file.
Contributing
See AGENTS.md for repository conventions, and
docs/DECISIONS.md for the reasoning behind the ones
that were not obvious.
Contributions are welcome! Please follow these steps:
-
Fork the repository.
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Run
just check && just test, then commit your changes and open a pull request.
License
This project is licensed under the MIT License.
Metadata
Release files for prusaslicer-py 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| prusaslicer_py-0.2.0.tar.gz | 111.9 kB | With provenance | Details for prusaslicer_py-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| prusaslicer_py-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for prusaslicer_py-0.2.0-py3-none-any.whl |
Total release size: 125.5 kB
Release files / prusaslicer_py-0.2.0.tar.gz
| Download URL | prusaslicer_py-0.2.0.tar.gz |
|---|---|
| Size | 111.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d42f363f245d1450c06b501dc95c5eca4ca4cfd08bc10aa2c0e99e33e498543
|
|
BLAKE2b-256 checksum How to use checksums |
8f1250dafc10eed0303e553170a1618308b14b8699a48d78b01fe8e57dfa3bde
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 7, 2026.
Transparency logRelease files / prusaslicer_py-0.2.0-py3-none-any.whl
| Download URL | prusaslicer_py-0.2.0-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c4ce09e0f7f67404e66fa146b5c2108b4badaaaf2ef9e69f0a838c1f42e8569
|
|
BLAKE2b-256 checksum How to use checksums |
8f3490472b1f8696176385568ab275b2e6d3633d3049ce0612609633b9cd8cb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 7, 2026.
Transparency logSecurity for prusaslicer-py 0.2.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for prusaslicer_py-0.2.0.tar.gz
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 Sep 7, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.