shortid
raw JSON → 0.1.2 verified Mon Apr 27 auth: no python
A short id generator for Python, producing compact, URL-friendly unique identifiers. Version 0.1.2 is the latest release; the library appears to be in maintenance mode with no recent updates.
pip install shortid Common errors
error ModuleNotFoundError: No module named 'shortid' ↓
cause The package is not installed.
fix
Run: pip install shortid
error ImportError: cannot import name 'ShortId' from 'shortid' ↓
cause Incorrect import path.
fix
Use: from shortid import ShortId
Warnings
gotcha ShortId() without arguments uses default alphabet (case-sensitive alphanumeric). Generated IDs are not cryptographically random; use secrets module if you need stronger uniqueness. ↓
fix If you need secure IDs, consider a different library or use secrets.token_urlsafe()
deprecated The library has not been updated since 2017 and may not support modern Python versions (3.10+). Build failures possible. ↓
fix Test with your Python version; if broken, consider alternatives like shortuuid or pyshorteners.
Imports
- ShortId wrong
import shortidcorrectfrom shortid import ShortId
Quickstart
from shortid import ShortId
sid = ShortId()
short_id = sid.generate()
print(short_id) # e.g., 'B1rH9k'