I have a string which contains the name of a library that I want to import. How can I import that library dynamically?
For example:
library = "mylibrary"
I have a string which contains the name of a library that I want to import. How can I import that library dynamically?
For example:
library = "mylibrary"
you can use python default function __import__
to import modules.
mod = __import__(module)
but path of this module need to be appended in sys.path
sys.path.insert(0, <path of module>)