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-nameVerified import paths — ran on the pinned version, not inferred.
Demonstrates resolving a class, a function, and a module by their string names using `resolve_name`.
For Python 3.9+, use `from pkgutil import resolve_name` directly. For older Python versions, continue using this backport.
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.
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')`.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.
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.
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`.