pip和conda的最佳做法,以确保一致性 [英] Best practices with pip and conda for consistency
问题描述
我知道关于pip
和conda
的共存和可互换性/不可互换性存在很多问题.这不是我的问题:我知道我的工作既需要使用,又需要使用,而且在大多数情况下,我的conda envs
都是可管理的混乱.
I know there are a lot of questions on the coexistence and interchangeability/non-interchangeability of pip
and conda
. That is not my question: I know I need both for my work, I use both, and for the most part, my conda envs
are a manageable mess.
这就是问题:有很多安装pip
的方法.我碰巧先走conda
,所以我的pip
是通过anaconda/bin/pip
进行的.这是我的机器上唯一的pip
.这是我的问题:
But here's the thing: there's many ways to install pip
. I happened to get conda
going first, so my pip
is through anaconda/bin/pip
. It is the only pip
on my machine. Here are my questions:
- 这明智吗?我是否希望我的
pip
是usr/bin/pip
并且独立于全局conda
?感觉不合情理. - 如果我通过说
brew
或easy_install
安装新的pip
,是否应该开始通过这个新的pip
下载软件包?那会很糟糕并且将所有事情搞砸吗?
- Is this sensible? Do I want my
pip
to beusr/bin/pip
and be independent of globalconda
? It feels not-sensible. - If I install a new
pip
through saybrew
oreasy_install
, should I start downloading packages through this newpip
? Would that be awful and mess everything up?
谢谢!
推荐答案
Pip始终需要安装Python版本,并且与该特定的Python安装相关.默认情况下,pip将自己的Python软件包安装到Python库目录中相关的site-packages
目录中.该目录的确切位置取决于您的操作系统以及conda的安装方式.
Pip always requires a version of Python to be installed, and is associated with that specific Python installation. By default, pip installs packages for its own Python, into the related site-packages
directory inside the Python library directory. The exact location of this directory depends on your operating system and how you installed conda.
如果通过Homebrew或其他Python安装程序安装pip,则不应使用该pip并期望将其安装为conda.因此,如果您创建一个新的conda环境,则不应期望该环境中的pip会将软件包安装到另一个环境中.
If you install pip via Homebrew or with another installation of Python, you should not use that pip and expect it to install for conda. For that matter, if you create a new conda environment, you should not expect that the pip in that environment will install packages into another environment.
pip有--user
选项,该选项将软件包安装到用户帐户的目录中(在* nix系统上,这是~/.local
;对于Windows,我不记得了).所有具有相同主要和次要版本号的Python版本都可以找到这些软件包.但是,不建议以这种方式在多个Python之间共享软件包的方式安装软件包,因为如果不同的Python是用不同的编译器编译的,则可能会遇到麻烦.
There is the --user
option to pip, which installs packages into a directory in your user account (on *nix systems, this is ~/.local
; I can't recall for Windows where this is). These packages will be able to be found by all Python versions with the same major and minor version number. However, it is not recommended to install packages with the intent of sharing them among several Pythons this way, because if the different Pythons were compiled with different compilers, you may run into trouble.
这篇关于pip和conda的最佳做法,以确保一致性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!