I want to test in script whether all the necessary libraries are installed or not, if not, install it. Here is my code:
libs = ['lib1','lib2','lib3']
def import_m(name):
try:
import name
except:
pip.main(['install',name])
import name #look at this line
for i in libs:
import_m(i)
print("Done importing %s." % i)
But when running it raise an exection:
ImportError: No module named name
The line mentioned with this exection are indicated by the comment.
How can I fix it?