importing a module when the module name is in a variable [duplicate] February 7, 2023 by Tarik You want the built in __import__ function new_module = __import__(modulename)