0

I am trying to make an auto install script for the modules i use the most but I am having trouble trying to figure out how to use a variable for the import.The end goal is for it to go through a loop checking if they are installed and if not install them. I know how to install them in the script but it wont let me import with an array.

import pip
Check_libs=['pygame','pyttsx3']

for x in Check_libs:
    try:
        import (x)
        print(x, 'Is already installed')
    except:
        print(x,'is installing')
        pip._internal.main(['install', x])
PurpleLlama
  • 168
  • 1
  • 2
  • 14

0 Answers0