random-word
raw JSON → 1.0.13 verified Mon Apr 27 auth: no python
A simple Python package to generate random English words, suitable for password generation, game content, or testing. Version 1.0.13 requires Python 3.8+.
pip install random-word Common errors
error ConnectionError: Failed to fetch word from API ↓
cause Network unavailable or API endpoint changed.
fix
Check internet connection. Alternatively, use a local word list from another library (e.g., nltk) and bypass random-word.
error AttributeError: module 'random_word' has no attribute 'RandomWord' ↓
cause Wrong import: using 'import random_word' instead of 'from random_word import RandomWord'.
fix
Use
from random_word import RandomWord. Warnings
gotcha The package relies on a remote API (https://random-word-api.herokuapp.com). Without internet access, it raises a ConnectionError. ↓
fix Ensure network connectivity or use a local word list alternative. The package does not ship its own word list.
deprecated The method `random_word` was renamed to `get_random_word` in v1.0.0. The old name still works but issues a deprecation warning. ↓
fix Use `r.get_random_word()` instead of `r.random_word()`.
Imports
- RandomWord wrong
from random_word import random_wordcorrectfrom random_word import RandomWord
Quickstart
from random_word import RandomWord
r = RandomWord()
print(r.get_random_word())