LibGravatar
raw JSON → 1.0.4 verified Fri May 01 auth: no python
A Python 3 library providing an interface to the Gravatar API. Version 1.0.4 (latest) includes support for FIPS-enabled systems and drops Python 3.6. Release cadence is low (major versions years apart).
pip install libgravatar Common errors
error ModuleNotFoundError: No module named 'libgravatar' ↓
cause Library not installed or installed under a different name (e.g., gravatar).
fix
Run: pip install libgravatar
error AttributeError: 'Gravatar' object has no attribute 'get_image' ↓
cause The method may have been renamed or not exist in older versions. The correct method is get_image().
fix
Use g.get_image() (no underscore separation).
error libgravatar.GravatarError: invalid email address ↓
cause The email provided fails basic validation (e.g., missing @).
fix
Check the email string for typos. Ensure it contains '@' and a valid domain.
Warnings
breaking In version 1.0.0, the default for use_ssl changed from False to True. All URLs now use HTTPS by default. If your code relied on HTTP, update accordingly. ↓
fix Explicitly set use_ssl=False if you need HTTP: Gravatar(email, use_ssl=False)
deprecated Python 3.6 support was removed in version 1.0.4. If you are on Python 3.6, you must stay on an older version or upgrade Python. ↓
fix Upgrade to Python 3.7+ or pin libgravatar to 1.0.3.
gotcha The get_image() method returns a URL string, not the image binary. To download the image, you need an HTTP request. ↓
fix Use requests.get(g.get_image()) to get the actual image data.
Imports
- Gravatar
from libgravatar import Gravatar
Quickstart
from libgravatar import Gravatar
g = Gravatar('user@example.com')
print(g.get_image()) # URL of avatar