conda环境中conda和pip安装之间的区别 [英] Difference between conda and pip installs within a conda environment

查看:1796
本文介绍了conda环境中conda和pip安装之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我开始使用conda环境(Anaconda),我似乎在问自己很多问题,但是我最终还是使用Google搜索了.

我现在在自己的conda环境中运行所有项目,因为我希望将所有内容保持独立,并且对其他程序的依赖性尽可能小.例如,最近的环境:

conda create -n RL numpy tensorflow-gpu

然后我激活环境,并意识到哦-我忘了安装健身室".在这种情况下,这仅在PIP包管理器中可用,因此我只需键入pip install gym.但是在其他情况下,如果该软件包位于conda和pip中,则安装它的最佳方法是什么?

conda install package pip install package

或者换句话说-有什么区别?

为了提供完整的图片,我正在Ubuntu 16.04中运行所有程序,并根据项目在python 2和3之间切换.所以我的某些conda环境在python 2中,有些在python 3中.我发现有时python 3需要pip3 install,但并非总是如此-为什么?

第二,我的路径链接到Anaconda3目录中的python设置.

我当前的想法是,如果我通过conda安装,它将直接安装到我的环境中,但是通过pip它会安装到我的anaconda3站点程序包中,从而使其可用于我的Anaconda3目录下的所有conda环境.如果是这样的话,这意味着如果我在一个conda环境中pip install gym,它也应该在所有其他环境中都可用-但据我所知,这不是环境的预期行为.

请随时纠正我的假设并敲打我的头脑!

解决方案

据我对Conda的理解,它可以为您管理所有依赖项.例如,如果您有一个需要另一个软件包(例如numpy)的软件包(例如pandas),它将下载这两个软件包(警告您之后).

conda变得有用的地方是有时特定的软件包需要另一个版本的特定版本(例如4.3或更高版本),并且它们可能是软件包之间的冲突.需求和冲突定义了一个数学问题,这要归功于SAT解算器.

您可以在此处找到相关信息和链接: https://www.continuum.io/blog/developer/new-advances-conda-0

因此,每次您安装新软件包时,它将升级(如果有冲突,有时会降级)其他软件包,以确保每个软件包的功能.性格方面,我选择conda并仅在conda

不管理软件包的情况下使用pip

如果您对conda感兴趣,则为另一个链接: https://jakevdp.github.io/blog/2016/08/25/conda-myths-and-misconceptions/

关于pip3,它是同时安装了Python 2和Python 3时使用的名称,以避免命令中的冲突.在python 3环境中,命令pip将等效于pip3.

对于pip的行为,我可以确认安装仅在活动环境中完成,而其他环境不可用

I seem to be asking myself this question a lot, having recently switched to using conda environments (Anaconda), but I end up Googling and not getting too far.

I now run all my projects within their own conda environments, as I like to keep everything as separate and with as little dependencies on other programs as possible. For example, a recent environment:

conda create -n RL numpy tensorflow-gpu

Then I activate the environment, and realise "Oh - I forgot to install gym". In this case, this is only available in the PIP package manager, and so I simply type pip install gym. But in other cases, where the package exists within conda and pip, what is the best way to install it?

conda install package pip install package

Or in other words - what is the difference?

To provide the full picture, I'm running everything in Ubuntu 16.04, and switch between python 2 and 3 depending on the project. So some of my conda environments are in python 2, some are python 3. I've found that sometimes a pip3 install is required for python 3, but not always - why is this?

Secondly, my path links to the python setup in my Anaconda3 directory.

My current idea is that if I install via conda, it installs directly to my environment, but via pip it installs to my anaconda3 site-packages, making it available to all conda environments under my Anaconda3 directory. If this is the case, this means that if I pip install gym in one conda environment, it should also be available in all others - but this isn't the expected behaviour of environments as far as I am aware.

Please feel free to correct my assumptions and knock some sense into me!

解决方案

For my understanding of Conda that, it manages for you all the dependencies. For example if you have a package (like pandas) that requires another package (like numpy), it will download both (after warning you).

Where conda is becoming handy is that sometimes a specific package requires a specific version of another one (4.3 or later for example) and they can be conflicts between the packages. The requirements and conflicts define a mathematical problem that can be solved thanks to a SAT solver.

You can find informations and link about that here: https://www.continuum.io/blog/developer/new-advances-conda-0

So each time you are installing a new package, it will upgrade (or sometimes downgrade if conflicts) other packages to ensure the functionning of each package. Personnaly, I go with conda and use pip only when the package is not managed by conda

Another link if you are interested by conda: https://jakevdp.github.io/blog/2016/08/25/conda-myths-and-misconceptions/

About pip3, it is the naming used when you have both Python 2 and Python 3 installed, to avoid conflicts in the command. In a python 3 environment, the command pip will be equivalent to pip3.

For the behavior of pip, I can confirm that the installation is done only in the active environment and is not available to the other ones

这篇关于conda环境中conda和pip安装之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆