Using conda install within a python script

前端 未结 6 1982
后悔当初
后悔当初 2021-02-04 02:13

According to this answer you can import pip from within a Python script and use it to install a module. Is it possible to do this with conda install?

The co

6条回答
  •  無奈伤痛
    2021-02-04 02:49

    The simpler thing that i tried and worked for me was :

    import os
    
    try:
        import graphviz
    except:
        print ("graphviz not found, Installing graphviz ")
        os.system("conda install -c anaconda graphviz")
        import graphviz
    

    And make sure you run your script as admin.

提交回复
热议问题