conda 可以全局安装包还是所有包都安装到特定环境?

Can conda install package globally or are all package installed to a specific environment?(conda 可以全局安装包还是所有包都安装到特定环境?)
本文介绍了conda 可以全局安装包还是所有包都安装到特定环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我的 conda 管理下有多个环境,如下所示

I have multiple environments under my conda management, as shown below

ss-MacBook-Pro$ conda env list
# conda environments:
#
base                  *  /miniconda2
testenv                  /miniconda2/envs/testenv
testenvpy3               /miniconda2/envs/testenvpy3

我可以安装一个可以在多个环境中生效的软件包吗?通过阅读 文档,我的印象是不可能,因为如果我这样做了

Can I install a package that becomes effective across multiple environments? By reading the documentation, I got the impression that it is NOT possible, because if I do

conda install package-name

它只会安装到 base 环境(当前活动环境)中,但不适用于其他环境.我记得我以前可以通过某种方式实现在virtualenv下安装一个对多个环境有效的包.

it will only get installed into the base environment (the current active environment), but it does not apply to other environments. I remember I can somehow achieve install a package effective to multiple environments under virtualenv before.

有人可以分享这个建议吗?

Can someone share the suggestion?

推荐答案

conda install 只为当前(激活的)环境安装包.文件将安装在特定环境的目录中.如果您想在所有环境中使用特定包,则必须为每个环境(basetestenvtestenvpy3).

conda install only installs packages for the current (activated) environment. Files will be installed in the directory for the specific environment. If you want a specific package in all environments, you'll have to conda install that package for each of your environments (base, testenv, testenvpy3).

要在环境之间切换,您只需激活您切换到的环境.语法取决于 Anaconda 版本或您的操作系统.对于较新的 Anaconda 版本,conda activate 有效,对于旧版本,source activate 适用于 Unix 系统和 activate <环境名称> 适用于 Windows.

To switch between environments you just need to activate the one you switch to. The syntax depends Anaconda version or your OS. For newer Anaconda versions, conda activate <env name> works, and for older versions, source activate <env name> for Unix systems and activate <env name> for Windows.

我确定您已经看过这个,但这里有一个有用的 链接.

I'm sure you've looked at this already, but here's a helpful link.

这篇关于conda 可以全局安装包还是所有包都安装到特定环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

python arbitrarily incrementing an iterator inside a loop(python在循环内任意递增迭代器)
Joining a set of ordered-integer yielding Python iterators(加入一组产生 Python 迭代器的有序整数)
Iterating over dictionary items(), values(), keys() in Python 3(在 Python 3 中迭代字典 items()、values()、keys())
What is the Perl version of a Python iterator?(Python 迭代器的 Perl 版本是什么?)
How to create a generator/iterator with the Python C API?(如何使用 Python C API 创建生成器/迭代器?)
Python generator behaviour(Python 生成器行为)