在同一环境中使用 conda 和 pip install 是一个坏主意吗? [英] Is that a bad idea to use conda and pip install on the same environment?

查看:30
本文介绍了在同一环境中使用 conda 和 pip install 是一个坏主意吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 conda installpip install 在许多情况下做的事情本质上是一样的,那么最好的选择是什么?有没有人应该只坚持 pip install 的情况?对称,是否有一种情况应该只坚持 conda install?有没有办法在同一个环境中同时使用 conda 和 pip install 来解决问题?

Since conda install and pip install in many cases do essentially the same thing, what would be the best option? Is there a case when someone should stick to pip install only? Symmetrical, is there a case when one should stick to conda install only? Is there a way to shoot in one's foot by using both conda and pip install in a single environment?

如果两种方法在本质上是相同的并且不相互矛盾,那么就没有理由只坚持其中一种而不是另一种.

If both approaches are essentially the same and don't contradict each other there should be no reason to stick solely to one of them but not to the other.

推荐答案

不要在 conda 环境中混合使用 conda installpip install.可能,决定一劳永逸地使用 condavirtualenv+pip .以下是您决定哪一种最适合您的方法:

Don't mix conda install and pip install within conda environment. Probably, decide to use conda or virtualenv+piponce and for all. And here is how you decide which one suits you best:

  • Conda 在 conda 环境中安装各种(不仅是 Python)conda 采用的软件包.如果您喜欢环境,它可以让您的环境正确.
  • Pip 在 Python 环境中安装 Python 包(virtualenv 就是其中之一).它可以正确安装您的 python 包.

使用 conda 的安全方法:不要急于获取最新的东西并坚持使用可用的软件包,你会没事的.

Safe way to use conda: don't rush for the latest stuff and stick to the available packages and you'll be fine.

使用 pip+virtualenv 的安全方法:如果您看到依赖项问题或希望在打包后删除和清理 - 不要.只是烧掉房子,放弃你的旧环境并创造一个新的环境.一个命令行,2-5 分钟后,一切又会变得整洁.

Safe way to use pip+virtualenv: if you see a dependency issue or wish to remove and clean up after package - don't. Just burn the house, abandon your old environment and create a new one. One command line and 2-5 minutes later things gonna be nice and tidy again.

Pip 是其中最好的安装 Python 包的工具.由于 pip 包通常首先出现,然后才被 conda 采用(由 conda 员工或贡献者).很有可能,在更新或安装最新版本的 Python 之后,某些软件包只能通过 pip 获得.最新版本的软件包只能在 pip 中使用.将 pip 和 conda 包混合在一起可能是一场噩梦(至少如果您想利用 conda 的优势).

Pip is the best tool for installing Python packages among the two of them. Since pip packages normally come out first and only later are adopted for conda (by conda staff or contributors). Chances are, after updating or installing the latest version of Python some of the packages would only be available through pip. And the latest freshest versions of packages would only be available in pip. And mixing pip and conda packages together can be a nightmare (at least if you want to utilize conda's advantages).

Conda 在管理依赖项和复制环境方面是最好的.卸载包时,conda 可以自行清理,并且可以更好地控制冲突的依赖版本.此外,conda 可以导出环境配置,如果此时行星是正确的并且新机器没有太大不同,则在其他地方复制该环境.此外,conda 可以对环境有更大的控制,例如,可以在其中安装不同版本的 Python(virtualenv - 只有系统中可用的 Python).你总是可以创建一个conda包 当您没有选择使用什么的自由时.

Conda is the best when it comes to managing dependencies and replicating environments. When uninstalling a package conda can properly clean up after itself and has better control over conflicting dependency versions. Also, conda can export environment config and, if the planets are right at the moment and the new machine is not too different, replicate that environment somewhere else. Also, conda can have larger control over the environment and can, for example, have a different version of Python installed inside of it (virtualenv - only the Python available in the system). You can always create a conda package when you have no freedom of choosing what to use.

一些相关事实:

  • Conda 需要更多空间和时间来设置
  • 如果您没有系统管理员权限,Conda 可能会更好
  • Conda 将在您没有系统 Python 时提供帮助
  • virtualenv+pip 将使您免于了解大量此类细节

一些过时的观念:

  • 过去,Conda 曾经更适合新手开发人员(2012 年).不再有可用性差距
  • Conda 与 Continuum Analytics 有太多关联.现在 Conda 本身是开源的,包 - 不是那么多.

这篇关于在同一环境中使用 conda 和 pip install 是一个坏主意吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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