SVGWrite is a Python library for programmatically creating SVG (Scalable Vector Graphics) drawings. It enables developers to generate vector graphic shapes, text, and images as XML files. The library is currently in maintenance mode (version 1.4.3, last updated July 14, 2022), meaning it receives bug fixes but no new feature development. It focuses solely on writing SVG files and does not support reading or modifying existing SVG documents, though it can embed other SVGs as images.
pip install svgwriteVerified import paths — ran on the pinned version, not inferred.
This example creates a simple SVG file named 'test.svg' with a line and some red text. It demonstrates the basic steps of initializing a `Drawing` object, adding elements like `line` and `text`, and saving the output.
Ensure your project runs on Python 3.6 or newer. For older Python 3 versions, upgrade your environment. For Python 2, consider an older svgwrite version (e.g., <1.4) or migrating to Python 3.
If you need to read or modify existing SVG files, consider using a different library like `lxml` to parse the XML structure, or a dedicated SVG manipulation library.
Only enable `debug=True` during development for error detection. Remove or set `debug=False` for production builds to maintain performance.
Be aware that new features or significant API changes are unlikely. Plan your usage around the existing feature set and consider community forks or alternatives if advanced features or active development are critical.
pip install svgwrite
Remove the line attempting to parse or read an SVG file, as svgwrite only supports writing; use a different library (e.g., lxml, svgutils) for parsing SVG files.
Convert the flat list of coordinates into a list of (x, y) tuples: `dwg.polyline([(x1, y1), (x2, y2), ...])`
Create SVG elements using svgwrite's methods (e.g., `dwg.rect()`, `dwg.text()`) instead of attempting to add elements from other XML parsing libraries.
No dependency data recorded yet.