Install & Compatibility
Where this runs
tested against v5.16.1 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.064s · 18.5MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.7s · import 0.056s · 19MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
HasTraits
✓ from traitlets import HasTraits
Correct import path for defining classes with trait attributes.
Unicode
✓ from traitlets import Unicode
Correct import path for defining Unicode trait attributes.
Int
✓ from traitlets import Int
Correct import path for defining Integer trait attributes.
default
✓ from traitlets import default
Correct import path for defining default values for traits.
A simple example demonstrating the use of Traitlets to define a class with a 'username' attribute that defaults to the current system user.
import getpass
from traitlets import HasTraits, Unicode, default
class Identity(HasTraits):
username = Unicode()
@default('username')
def _default_username(self):
return getpass.getuser()
identity = Identity()
print(identity.username)
Errors
Common errors & fixes
TraitError: The 'my_trait' trait of a MyClass instance must be an int, but a value of 'hello' <class 'str'> was specified.
This error occurs when you attempt to assign a value of an incorrect type to a traitlet-defined attribute.
fixAssign a value that matches the traitlet's specified type (e.g., an `int` for an `Int` trait, a `str` for a `Unicode` trait).
traitlets.config.loader.ConfigError: No such config option: 'MyClass.some_nonexistent_trait'
This error indicates that a configuration file (e.g., for a Jupyter application) attempts to set a traitlet that either does not exist, is misspelled, or is not applicable to the specified class.
fixReview your configuration file and correct the traitlet option name, ensuring it matches an existing trait on the target class.
TypeError: _default_my_trait() missing 1 required positional argument: 'owner'
This error arises when you define a method to provide a dynamic default value for a traitlet (e.g., `_default_my_trait`) but omit the `owner` argument from its signature.
fixAdd the `owner` argument to the method signature: `def _default_my_trait(self, owner): return some_value`.
Upgrade
Version history
5.16.1latest on PyPI · released Aug 3, 2026
Audit
Dependencies
ipython_genutilsrequiredProvides utility functions for IPython components.
sixrequiredEnsures compatibility between Python 2 and 3.
decoratorrequiredSimplifies the creation of decorators.