Using conda install within a python script

前端 未结 6 1988
后悔当初
后悔当初 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:46

    You can use conda.cli.main. For example, this installs numpy:

    import conda.cli
    
    conda.cli.main('conda', 'install',  '-y', 'numpy')
    

    Use the -y argument to avoid interactive questions:

    -y, --yes Do not ask for confirmation.

提交回复
热议问题