Registry / data / pyclipper

pyclipper

JSON →
library1.4.0pypypi✓ verified 26d ago

Pyclipper is a Cython wrapper that exposes the public functions and classes of the C++ translation of the Angus Johnson's Clipper library (version 6.4.2). It provides robust algorithms for 2D polygon clipping (intersection, union, difference, XOR) and offsetting (inflating/deflating). The library is actively maintained, with the latest version being 1.4.0, and releases occur as needed for updates or Python compatibility.

pip install pyclipper
INSTALL
IMPORT
SIG · PYCLIPPER
P
pyclipper
datapythonv1.4.0
Install
1.6s avg
Import
10ms
Disk
19MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.0 · 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
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.010s · 22MB
19MB installed
● package 19MB
Code
Verified usage

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

pyclipper
import pyclipper
All core functionality is accessed through the `pyclipper` module.

This quickstart demonstrates basic polygon clipping and offsetting using `pyclipper`. It sets up subject and clip polygons, performs an intersection operation, and then an inward offset on a single polygon. All coordinates are integers, as required by the underlying Clipper library.

import pyclipper # Subject polygon (a list of paths, where a path is a list of (x, y) tuples) subj = ( ((180, 200), (260, 200), (260, 150), (180, 150)), ((215, 160), (230, 190), (200, 190)) ) # Clip polygon clip = ((190, 210), (240, 210), (240, 130), (190, 130)) # Initialize Clipper object pc = pyclipper.Pyclipper() # Add paths to the Clipper object pc.AddPath(clip, pyclipper.PT_CLIP, True) # Clip path is a closed polygon pc.AddPaths(subj, pyclipper.PT_SUBJECT, True) # Subject paths are closed polygons # Execute the clipping operation (intersection in this case) solution = pc.Execute( pyclipper.CT_INTERSECTION, pyclipper.PFT_EVENODD, # Fill type for subject polygons pyclipper.PFT_EVENODD # Fill type for clip polygons ) print(f"Intersection solution: {solution}") # Example of offsetting subj_offset = ((180, 200), (260, 200), (260, 150), (180, 150)) pco = pyclipper.PyclipperOffset() pco.AddPath(subj_offset, pyclipper.JT_ROUND, pyclipper.ET_CLOSEDPOLYGON) solution_offset = pco.Execute(-7.0) # Offset by -7 units (inward) print(f"Offset solution: {solution_offset}")
Debug
Known issues
breakingThe global `SCALING_FACTOR` variable was removed in version 1.0.0 (and its deprecated usage removed in 1.3.0). This change significantly impacted how floating-point coordinates were handled, as automatic scaling is no longer performed.
fix
Manually scale floating-point coordinates to integers before passing them to `pyclipper` functions using `pyclipper.scale_to_clipper()` and scale results back using `pyclipper.scale_from_clipper()`.
affects: >=1.0.0
gotchaThe underlying Clipper library operates exclusively on integer coordinates to ensure numerical robustness. Providing floating-point coordinates directly can lead to precision issues or unexpected behavior.
fix
Always convert your floating-point coordinates to integers by multiplying them with a suitable scaling factor (e.g., 1000000 for high precision) before passing them to `pyclipper`. Use `pyclipper.scale_to_clipper()` and `pyclipper.scale_from_clipper()` helper functions for convenience.
affects: All versions
breakingPython 3.9 support was dropped, and Python 3.10 or newer is now required.
fix
Ensure your project's Python environment is running Python 3.10 or a later version.
affects: >=1.4.0
gotchaWhen building `pyclipper` from source (e.g., from a Git clone or sdist), Cython is now always a mandatory dependency, even if pre-generated C++ sources are present in the sdist.
fix
If building from source, ensure Cython is installed in your build environment (`pip install Cython`). For typical `pip install pyclipper` from PyPI, pre-built wheels are usually provided, making Cython unnecessary.
affects: >=1.4.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyclipper'
The `pyclipper` library is either not installed in the active Python environment or the Python interpreter being used cannot find it.
fix
Ensure `pyclipper` is installed in your environment using `pip install pyclipper`. If you have multiple Python installations, use `python -m pip install pyclipper` to target the specific Python interpreter you are using.
ERROR: Failed building wheel for pyclipper
This error typically occurs during installation when `pip` attempts to build `pyclipper` from source but lacks the necessary C++ compilation tools or compatible Python development headers. This can happen on systems without developer tools (like Xcode Command Line Tools on macOS) or when using Python versions for which pre-compiled wheels are not available, or due to a mismatch in Cython/Python versions.
fix
Install the necessary build tools for your operating system (e.g., `xcode-select --install` on macOS, Visual Studio Build Tools on Windows). For Python version conflicts (e.g., with Python 3.9+ and older pyclipper versions), ensure you have an up-to-date `pip` and `setuptools`, and try installing a `pyclipper` version with pre-built wheels for your Python version, or upgrade Cython before attempting to install.
ImportError: DLL load failed: The specified module could not be found.
On Windows, this error indicates that a dependency of the `pyclipper` C++ extension (a Dynamic Link Library, DLL) could not be found. This is commonly due to missing Visual C++ Redistributable packages.
fix
Install the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, 2019, and 2022 (x64 and x86 versions) from the official Microsoft website. This provides the runtime components required by C++ compiled Python extensions.
terminate called after throwing an instance of 'ClipperLib::clipperException' what(): Error: PolyTree struct is need for open path clipping.
`pyclipper`'s underlying Clipper library requires a specific output structure (`PolyTree`) when performing clipping operations on open paths (e.g., lines). Using `Execute` instead of `Execute2` for such cases will lead to this exception.
fix
When clipping open paths, use `pc.Execute2()` instead of `pc.Execute()` as `Execute2` is designed to return a `PolyTree` structure suitable for open path clipping.
Upgrade
Version history
1.4.0latest on PyPI · released Dec 1, 2025
Audit
Dependencies
pythonrequiredRequires Python 3.10 or newer.
CythonoptionalRequired to build pyclipper from source. Not needed for pip installs from wheels.
Agent activity
25 hits · last 30 days
node
20
Amazon
1
Resources
pyclipper — pip install pyclipper · libregistry