Install & Compatibility
Where this runs
tested against v2.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.003s · 17.8MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
generate
✓ import petname
petname.generate()
✗ from petname import PetName; PetName.generate()
The primary function `generate` is typically accessed directly as a method of the imported `petname` module, not from an instantiated class. Older examples might show a class or direct functions like `adverb()` or `name()`, but `generate()` is the main entry point for a full name.
Adjective
✓ import petname
petname.Adjective()
While `generate` is preferred for full names, individual word types can still be accessed directly.
Adverb
✓ import petname
petname.Adverb()
Individual word types can be accessed directly.
Name
✓ import petname
petname.Name()
Individual word types can be accessed directly.
Generate human-readable names with varying word counts and separators. The `generate()` function is the primary API. You can also access specific word types like adjectives, adverbs, or names directly.
import petname
# Generate a two-word name (default)
name1 = petname.generate()
print(f"Generated name: {name1}")
# Generate a three-word name with a custom separator
name2 = petname.generate(3, '_')
print(f"Generated name: {name2}")
# Generate a single-word name with max letters
name3 = petname.generate(1, max_letters=5)
print(f"Generated name: {name3}")
# Generate words from specific categories
adjective = petname.Adjective()
print(f"Random adjective: {adjective}")
petname --version
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'petname'
The 'petname' library is not installed in your current Python environment or the module name is misspelled.
fixInstall the library using pip: `pip install petname`
AttributeError: module 'petname' has no attribute 'generate'
You attempted to call a function or access an attribute named 'generate' (lowercase 'g'), but the primary name-generating function in the 'petname' library is 'Generate' (with an uppercase 'G').
fixUse the correct function name: `petname.Generate()`
TypeError: Generate() missing 1 required positional argument: 'words'
The `petname.Generate()` function was called without providing a value for the 'words' argument, which specifies the number of words in the generated name and is often expected even if it has a default in some contexts.
fixProvide the 'words' argument, e.g., `petname.Generate(words=2)`
ImportError: cannot import name 'generate' from 'petname'
You tried to import a specific function named 'generate' (lowercase 'g') directly from the 'petname' package, but the function is named 'Generate' (uppercase 'G') and is typically accessed as an attribute of the imported module, e.g., `petname.Generate`.
fixImport the module itself and call the function, or correct the casing: `import petname; petname.Generate()` or `from petname import Generate` (if 'Generate' is explicitly exposed).
AttributeError: partially initialized module 'petname' has no attribute 'Generate'
A local Python file in your working directory is named 'petname.py', which 'shadows' the installed 'petname' library. Python imports your local file instead of the actual library, and your local file doesn't define the 'Generate' function.
fixRename your local Python file (e.g., from `petname.py` to `my_petname_script.py`) to avoid the name conflict.
Upgrade
Version history
2.9latest on PyPI · released Feb 15, 2026
Audit
Dependencies
No dependency data recorded yet.