gpt4 book ai didi

python - 有一种快速的方法可以知道 Anaconda 中是否安装了一个包

转载 作者:行者123 更新时间:2023-12-05 06:11:15 26 4
gpt4 key购买 nike

在Anaconda中安装一个包至少需要15秒,如果包已经安装解析环境仍然需要时间:

time /opt/Anaconda3-2019.10/bin/conda install --override-channels --quiet -y plotly-orca
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

# All requested packages already installed.


real 0m15.067s
user 0m13.533s
sys 0m0.401s

但是检查包(无论版本)是否安装只需要 2 秒:

time /opt/Anaconda3-2019.10/bin/conda list --quiet plotly-orca
# packages in environment at /opt/Anaconda3-2019.10:
#
# Name Version Build Channel
plotly-orca 1.3.1 1 plotly

real 0m2.303s
user 0m2.227s
sys 0m0.064s

我知道我可以围绕这个做一些 Shell 脚本,但是有更好的方法来安装一个包,如果不存在的话?

conda 是否有可用于检查此问题的 API(类似于 pip)?

我查看了 with conda install --help 上的所有选项,没有发现我可以使用的东西(--satisfied-skip-solve 似乎对已经安装的包有帮助,但它是否打破了新的安装?)。

谢谢!

最佳答案

作为Merv mentions in a comment:

Yeah, -S|--satisfied-skip-solve addresses this. You can do dry runs (-d) to test its behavior for new packages - works fine for me. Seems like you already answered your own question. I would note you may want to also include a --update-specs flag: this tells Conda that you explicitly want the package(s) in the environment into the future. This addresses the situation of packages that installed only as dependencies and would normally be removed were the depending package removed.

关于python - 有一种快速的方法可以知道 Anaconda 中是否安装了一个包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64068741/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com