pip和conda的最佳做法,以确保一致性 [英] Best practices with pip and conda for consistency

查看:467
本文介绍了pip和conda的最佳做法,以确保一致性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道关于pipconda的共存和可互换性/不可互换性存在很多问题.这不是我的问题:我知道我的工作既需要使用,又需要使用,而且在大多数情况下,我的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:

  1. 这明智吗?我是否希望我的pipusr/bin/pip并且独立于全局conda?感觉不合情理.
  2. 如果我通过说breweasy_install安装新的pip,是否应该开始通过这个新的pip下载软件包?那会很糟糕并且将所有事情搞砸吗?
  1. Is this sensible? Do I want my pip to be usr/bin/pip and be independent of global conda? It feels not-sensible.
  2. If I install a new pip through say brew or easy_install, should I start downloading packages through this new pip? 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屋!

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