Python third-party library automatic installation script

Requirements: Batch installation of third-party libraries requires manual intervention, can they be installed automatically?

Now suppose we want to install the following libraries
Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

#BatchInstall.py
import os
libs = {
    
    "numpy","matplotlib","pillow","sklearn","requests",\
"jieba","beautifulsoup4","wheel","networkx","sympy",\
"pyinstaller","django","flask","werobot","pyqt5",\
"pandas","pyopengl","pypdf2","docopt","pygame"}

try:
    for lib in libs:
        os.system("pip install" + lib)
    print("Successful")
except:
    print("Failed Somehow")

Source: BIT python MOOC

Guess you like

Origin blog.csdn.net/weixin_44997802/article/details/108232556
Recommended