python: A way to automatically install missing library files

  • 2020-12-26 05:49:13
  • OfStack

Method

It can be completed through 1 instruction:


os.system(' The required instruction ')

Note:

os.system (' required instruction ') can also do many other tasks and is very powerful.

Example


try:
 from tqdm import tqdm
except:
 import os
 os.system('sudo pip3 install tqdm')
 from tqdm import tqdm

Related articles: