简体   繁体   English

如果同时需要 conda 和 pip 的包怎么办?

[英]What to do if you need packages from both conda and pip?

I've been developing my project with pip (django, drm etc).我一直在用 pip(django、drm 等)开发我的项目。 Now I need to use faiss, which only has unofficial package on pip (official - in conda).现在我需要使用 faiss,它只有 pip 上的非官方 package(官方 - 在 conda 中)。 What should I do in this situation?遇到这种情况怎么办? Can I combine them somehow?我能以某种方式组合它们吗? Or should I migrate to conda?还是应该迁移到 conda?

If you're using a non-conda environment, then you're limited to using pip only.如果您使用的是非 conda 环境,则只能使用pip That is, pip does not know how to install conda packages.pip不知道怎么安装conda包。

But if you switch to using conda , then you can use either.但是如果你切换到使用conda ,那么你可以使用任何一个。 The general recommendation is to install everything with conda if possible, but use pip when you have no other choice.一般建议是尽可能使用conda安装所有内容,但如果别无选择,请使用pip

I recommend installing Miniconda , then creating a new environment for all of your dependencies.我建议安装Miniconda ,然后为所有依赖项创建一个新环境。 If necessary, add pip -only dependencies (if you have any).如有必要,添加pip依赖项(如果有的话)。

conda create --name alex python=3.8 pip django requests bla-bla-bla
conda activate alex
pip install drm foo bar yada-yada

If you need uncommon or bleeding-edge packages, you might also consider obtaining your conda packages from the conda-forge channel, rather than the defaults channel.如果您需要不常见或前沿的包,您还可以考虑从conda-forge频道而不是defaults频道获取您的 conda 包。 See here for instructions. 有关说明,请参见此处。

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

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