Import modules after compilation with py2exe

137 views Asked by At

I compiled a python executable with py2exe and want to import a python module by a user input.

userinput = input("Enter module name")
module = __import__(userinput)

Does this work? Or is there another way to import a module after the file is compiled?

1

There are 1 answers

0
Bharadwaj On BEST ANSWER

You could try importlib.import_module():

import importlib
importlib.import_module(userinput)