pybadges
raw JSON → 3.0.1 verified Fri May 01 auth: no python
A library and command-line tool for generating Github-style badges (SVG images). Current version: 3.0.1, requires Python >=3.4, release cadence is irregular.
pip install pybadges Common errors
error ModuleNotFoundError: No module named 'pybadges.badge' ↓
cause Importing `from pybadges.badge import badge` (submodule) instead of `from pybadges import badge`.
fix
Use
from pybadges import badge. error AttributeError: module 'pybadges' has no attribute 'generate_badge' ↓
cause Using the old function name `generate_badge` which was removed in version 3.0.0.
fix
Use
badge(...) instead. Warnings
breaking In version 3.0.0, the import path and function signature changed. `from pybadges import badge` is the only supported import; the old `generate_badge` function was removed. ↓
fix Use `from pybadges import badge` and call `badge(left_text='...', right_text='...', ...)`.
deprecated The command-line tool `pybadges` is still available but may be deprecated in future releases. Use programmatic API instead. ↓
fix Use `from pybadges import badge` in Python scripts.
gotcha The `whole_link` parameter does not exist. To make the whole badge clickable, use `<a>` tags around the SVG output manually. ↓
fix Wrap the SVG string with `<a href="...">...</a>` in your HTML.
Imports
- badge wrong
from pybadges import Badge from pybadges import generate_badgecorrectfrom pybadges import badge
Quickstart
from pybadges import badge
svg = badge(left_text='version', right_text='3.0.1', right_color='green')
print(svg[:100]) # prints first 100 characters of SVG