You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为指定Python环境通过requirements.txt安装依赖包?

问题解答

你的命令写法存在错误,不能直接在指定Python路径后接pip install,正确的执行方式有两种:

  • 直接调用目标Python环境对应的pip路径
    通常pip会和Python二进制文件位于同一目录,执行以下命令即可:

    /opt/conda/envs/prod/bin/pip install -r /home/jupyter/services/requirements.txt
    
  • 通过-m pip参数让指定Python版本调用pip模块
    这种方式能确保使用的是目标Python对应的pip,避免环境混淆,命令如下:

    /opt/conda/envs/prod/bin/python -m pip install -r /home/jupyter/services/requirements.txt
    

另外需要注意:你给出的示例命令中requirements.txt路径是/home/jupyter/ml_gcp_services/requirements.txt,但描述里的实际路径是/home/jupyter/services/requirements.txt,执行时要确认路径一致,防止出现文件找不到的错误。

内容的提问来源于stack exchange,提问作者renaudb3

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 14:36:22