Solve the problem of missing modules for python automatic installation

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

scenario

I write a script for someone else to use, but this script contains a third library.

Of course, the other side will prompt the lack of execution, can you let python automatically installed?

To solve


try:
 import requests
except :
 import os
 os.system('pip install requests')
 import requests

Related articles: