I wanted to install and import a package from script. Then I wanted to add from x import y
and from x import *
in that script.(I was making some functions actually).
I successfully installed and imported using subprocess
and importlib
. But I'm at a loss in from x import y
and from x import *
. Tried these codes and some others.
globals()[package] = importlib.import_module('package','class')
globals()[package] = importlib.import_module('class','package')
globals()[package] = importlib.import_module('package','*')
globals()[package] = importlib.import_module('*','package')
importlib.import_module('gtts','gTTS')
importlib.import_module('gtts','*')
But they didn't work. Shows:
NameError: name 'gTTS' is not defined
ModuleNotFoundError: No module named 'gTTS'
etc.