pkgutil-resolve-name
raw JSON → 1.3.10 verified Tue May 12 auth: no python install: verified
pkgutil-resolve-name is a Python library that provides a backport of the `pkgutil.resolve_name` function, originally introduced in Python 3.9. It allows resolving a string-based name (e.g., 'module.submodule:ClassName' or 'module.function_name') to its corresponding Python object. The current version is 1.3.10, with an infrequent release cadence as it primarily backports a standard library feature.
pip install pkgutil-resolve-name Common errors
error ValueError: invalid format: 'module-with-dash.ClassName' ↓
cause The string passed to `pkgutil.resolve_name` contains characters (like a hyphen '-') that are not valid in Python identifiers, violating the expected format of 'module.submodule:ClassName' or 'module.function_name'.
fix
Ensure the module and object names adhere to valid Python identifier naming conventions, using underscores instead of hyphens where appropriate. For example,
pkgutil.resolve_name('module_with_underscore.ClassName'). error AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'? ↓
cause This error typically occurs in Python 3.12 and later when older versions of tools like `pip` or `setuptools` (or packages that rely on them) attempt to use the `pkgutil.ImpImporter` class, which was removed from the standard library in Python 3.12.
fix
Upgrade
pip and setuptools to their latest versions within your environment (e.g., python -m pip install --upgrade pip setuptools). If the issue persists, ensure all other dependencies are updated, or consider using a Python version older than 3.12 if a specific legacy package cannot be updated. error AttributeError: module 'my_module' has no attribute 'NonExistentClass' ↓
cause `pkgutil.resolve_name` successfully imported the specified module, but could not find the named object (e.g., class, function, or variable) within that module.
fix
Verify that the object path provided to
pkgutil.resolve_name exactly matches an existing object within the specified module. Double-check for typos or incorrect casing. error ModuleNotFoundError: No module named 'non_existent_module' ↓
cause `pkgutil.resolve_name` was unable to locate or import the module specified in the input string, meaning the module does not exist or is not in the Python path.
fix
Ensure the module name is spelled correctly and that the module is installed and accessible within the current Python environment (e.g., listed in
sys.path). If it's a third-party package, install it using pip install non_existent_module. Warnings
gotcha This library is a backport of `pkgutil.resolve_name` from Python 3.9. If your project targets Python 3.9 or newer, you can directly use `pkgutil.resolve_name` from the standard library without needing this external package. ↓
fix For Python 3.9+, use `from pkgutil import resolve_name` directly. For older Python versions, continue using this backport.
breaking The `resolve_name` function (both this backport and the standard library version) allows resolving arbitrary Python objects by string. This can be a security footgun, especially in contexts involving untrusted input or deserialization (e.g., `pickle`). An attacker could potentially use this to load and execute dangerous functions or modules, bypassing blocklists. ↓
fix Avoid using `resolve_name` with untrusted input strings. Implement robust validation or an allow-list for acceptable object paths if dynamic resolution is absolutely necessary in security-sensitive applications. Consider alternative approaches that do not rely on dynamic string-to-object resolution for critical operations.
Install compatibility verified last tested: 2026-05-12
python os / libc status wheel install import disk
3.10 alpine (musl) wheel - 0.00s 17.8M
3.10 alpine (musl) - - 0.00s 17.8M
3.10 slim (glibc) wheel 1.5s 0.00s 18M
3.10 slim (glibc) - - 0.00s 18M
3.11 alpine (musl) wheel - 0.00s 19.6M
3.11 alpine (musl) - - 0.00s 19.6M
3.11 slim (glibc) wheel 1.5s 0.00s 20M
3.11 slim (glibc) - - 0.00s 20M
3.12 alpine (musl) wheel - 0.00s 11.5M
3.12 alpine (musl) - - 0.00s 11.5M
3.12 slim (glibc) wheel 1.4s 0.00s 12M
3.12 slim (glibc) - - 0.00s 12M
3.13 alpine (musl) wheel - 0.00s 11.2M
3.13 alpine (musl) - - 0.00s 11.1M
3.13 slim (glibc) wheel 1.4s 0.00s 12M
3.13 slim (glibc) - - 0.00s 12M
3.9 alpine (musl) wheel - 0.00s 17.3M
3.9 alpine (musl) - - 0.00s 17.3M
3.9 slim (glibc) wheel 1.7s 0.00s 18M
3.9 slim (glibc) - - 0.00s 18M
Imports
- resolve_name
from pkgutil_resolve_name import resolve_name
Quickstart last tested: 2026-04-24
from pkgutil_resolve_name import resolve_name
# Resolve a class from a standard library module
Path = resolve_name('pathlib:Path')
print(f"Resolved object: {Path}")
print(f"Is it the pathlib.Path class? {Path.__name__ == 'Path' and Path.__module__ == 'pathlib'}")
# Resolve a function
sys_exit = resolve_name('sys:exit')
print(f"Resolved object: {sys_exit}")
print(f"Is it the sys.exit function? {sys_exit.__name__ == 'exit' and sys_exit.__module__ == 'sys'}")
# Resolve a module directly
collections_module = resolve_name('collections')
print(f"Resolved object: {collections_module}")
print(f"Is it the collections module? {collections_module.__name__ == 'collections'}")