Installing python module within code

前端 未结 7 1202
孤独总比滥情好
孤独总比滥情好 2020-11-21 23:31

I need to install a package from PyPi straight within my script. Maybe there\'s some module or distutils (distribute, pip etc.) featur

7条回答
  •  灰色年华
    2020-11-22 00:13

    This should work:

    import subprocess
    
    def install(name):
        subprocess.call(['pip', 'install', name])
    

提交回复
热议问题