简体   繁体   English

在conda环境中将pip用作低优先级“通道”

[英]using pip as a low priority 'channel' in conda environment

Is there a way to use pip as a 'fallback' option for some packages in a conda environment, like you can have multiple prioritized conda channels? 有没有一种方法可以将pip用作conda环境中某些软件包的“后备”选项,例如您可以拥有多个优先的conda通道?

For normal conda channels, my environment.yml would be as follows: 对于普通的conda频道,我的environment.yml如下:

name: my_env
channels:
  - defaults
  - conda-forge
dependencies:
  - some-package>=1.2.3

Where some-package would be installed from default channels if possible, or conda-forge otherwise. 如果可能的话,将通过默认通道安装some-package ,否则,将使用conda-forge进行安装。 It would fail if neither channel has the appropriate package version. 如果两个通道都没有合适的软件包版本,它将失败。

The environment.yml with pip: 带有pip的environment.yml:

name: my_env
channels:
  - defaults
  - conda-forge
dependencies:
  - pip
  - pip:
    - some-package>=1.2.3

Where some-package would always come from pip. some-package 总是来自点子。

But what I want is something like this: 但是我想要的是这样的:

name: my_env
channels:
  - defaults
  - conda-forge
dependencies:
  - some-package>=1.2.3
  - pip
  - pip:
    - some-package>=1.2.3

Where the package would come from defaults first, else conda-forge, or else from pip. 软件包将首先来自默认值,否则来自conda-forge,或者来自pip。
However, this gives a ResolvePackageNotFound error before trying pip. 但是,这会在尝试pip之前给出ResolvePackageNotFound错误。 Is there any way to achieve this? 有什么办法可以做到这一点?

I've read somewhere that conda shall be extended to allow satisfying dependencies with pip-installed packages. 我读过某处内容,应该扩展conda以允许使用pip安装的软件包满足令人满意的依赖关系。 But I cannot find the reference with a quick search, and I don't think it's a production-ready feature anyway. 但是我无法通过快速搜索找到参考,而且我也不认为这是可用于生产的功能。 And what I remember was not conda installing pip packages, but conda accepting already present packages that have been installed by pip. 我记得不是conda安装pip软件包,而是conda接受pip已安装的已经存在的软件包。

Anaconda packages define their dependencies in terms of other Anaconda packages. Anaconda包根据其他Anaconda包定义了它们的依赖关系。 Therefore, conda resolves dependencies of Anaconda packages within its own world of packages and metadata. 因此, conda解决了Anaconda软件包在其自身的软件包和元数据世界中的依赖性。 Some packages don't even have the same name in Anaconda channels and on PyPI. 有些包甚至在Anaconda频道和PyPI中甚至没有相同的名称。

In other words: No, I don't think that what you want is possible. 换句话说:不,我认为您想要的是不可能的。 You'll have to call pip when you want something installed by pip . 你必须打电话pip ,当你想通过安装一些pip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM