'i am trying to use importlib.import_module(package_name, class_name) but facing the below error
Error occurred in import_library function ::: Traceback (most recent call last):
File "C:\Users\alok.jha\Anaconda3\envs\myenv_dedupe\lib\DataManipulationLib\data_manipulation.py", line 2984, in import_local_libs
interim_obj = importlib.import_module(package_name, class_name)
File "C:\Users\alok.jha\Anaconda3\envs\myenv_dedupe\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
i am trying to use importlib.import_module(package_name, class_name) but facing the below error
Solution 1:[1]
I'm facing similar problem, and here is my solution.
Supposing I want to import class Man from the path root.human
import importlib
package = importlib.import_module('root.human')
Then I can call the Man class by package.Man.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | david |
