Using conda install within a python script

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

    Try this:

    !conda install xyzpackage
    

    Please remember this has to be done within the Python script not the OS prompt.

    Or else you could try the following:

    import sys from conda.cli import main

    sys.exit(main())
    
    try:
        import conda
        from conda.cli import main
        sys.argv = ['conda'] + list(args)
        main()
    

提交回复
热议问题