{"id":24674,"library":"svgutils","title":"svgutils - Python SVG Editor","description":"svgutils is a Python library for editing and manipulating SVG files. It allows you to create, transform, and combine SVG elements programmatically. Current version is 0.3.4. The library is in maintenance mode with infrequent releases.","status":"active","version":"0.3.4","language":"python","source_language":"en","source_url":"https://github.com/btel/svg_utils","tags":["svg","editing","graphics","vector"],"install":[{"cmd":"pip install svgutils","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"XML parsing and manipulation","package":"lxml","optional":false}],"imports":[{"note":"svglib is a different library for reading SVG files.","wrong":"import svglib","symbol":"svgutils","correct":"import svgutils"},{"note":"SVGFigure is in the compose module.","wrong":"from svgutils import SVGFigure","symbol":"SVGFigure","correct":"from svgutils.compose import SVGFigure"}],"quickstart":{"code":"from svgutils.compose import SVGFigure, Element, Text, Line\n# Create a new SVG figure\nfig = SVGFigure(width=200, height=200)\n# Add a text element\ntxt = Text('Hello, svgutils!', x=10, y=50, size=16, color='black')\n# Add a line\nline = Line(x1=10, y1=10, x2=100, y2=100, stroke='red')\n# Attach elements to figure\nfig.append(txt)\nfig.append(line)\n# Save to file\nfig.save('output.svg')","lang":"python","description":"Create a simple SVG with text and a line."},"warnings":[{"fix":"Use the compose API where possible; refer to examples on GitHub.","message":"svgutils.compose module is considered stable but older transform methods may be deprecated. Check for deprecation warnings.","severity":"deprecated","affected_versions":"<=0.3.4"},{"fix":"Set viewBox explicitly via SVGFigure attributes to control coordinate space.","message":"Element positions (x, y) are in SVG user units, not pixels. Scaling depends on viewBox.","severity":"gotcha","affected_versions":"all"},{"fix":"Call fig.append() before fig.save().","message":"All elements must be appended to a figure before saving. Attaching elements after save does not update file.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade to Python 3.6 or later.","message":"Python 2 support was dropped in version 0.3.0. Python 3.6+ required.","severity":"breaking","affected_versions":">=0.3.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use from svgutils.compose import SVGFigure","cause":"Incorrect import path. SVGFigure is in svgutils.compose.","error":"ImportError: cannot import name 'SVGFigure' from 'svgutils'"},{"fix":"Ensure the figure has at least one element appended and the output path is writable.","cause":"Attempting to save a figure with no attached elements or invalid path.","error":"AttributeError: 'NoneType' object has no attribute 'write'"},{"fix":"Verify the input SVG file is well-formed XML. Use fromstring() with proper encoding.","cause":"Opening a non-XML file or malformed SVG.","error":"lxml.etree.XMLSyntaxError: Start tag expected, ..."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}