微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用 Python 子进程在 linux 中激活 conda 虚拟环境

如何解决如何使用 Python 子进程在 linux 中激活 conda 虚拟环境

我只是想在 linux 中使用 python 激活 conda 虚拟环境。我正在使用子流程模块。当我在终端中使用 conda activate 时它工作正常,但这在 pyhton 中似乎不起作用。我的代码

subprocess.run('conda activate ENV_NAME',shell=True)

但是当我执行这个简单的代码时,出现以下错误

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell,run

    $ conda init <SHELL_NAME>

    Currently supported shells are:
      - bash
      - fish
      - tcsh
      - xonsh
      - zsh
      - powershell
    
    See 'conda init --help' for more information and options.
    
    IMPORTANT: You may need to close and restart your shell after running 'conda init'.

请帮帮我,我该怎么办?尝试了 stackoverflow 中的所有解决方案,但仍然出现相同的错误。谢谢!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。