Python “brew install”和“pip install”之间有区别吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32530506/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a difference between "brew install" and "pip install"?
提问by saulspatz
I want to install pillow on my Mac. I have python 2.7
and python 3.4
, both installed with Homebrew. I tried brew install pillow
and it worked fine, but only for python 2.7
. I haven't been able to find a way to install it for python 3
. I tried brew install pillow3
but no luck. I've found a post on SO that says to first install pip3
with Homebrew and then use pip3 install pillow
. As it happens, I have already installed pip3
.
我想在我的 Mac 上安装枕头。我有python 2.7
和python 3.4
,两者都安装了 Homebrew。我试过了brew install pillow
,效果很好,但仅适用于python 2.7
. 我一直无法找到安装它的方法python 3
。我试过了,brew install pillow3
但没有运气。我在 SO 上找到了一篇帖子,说首先pip3
使用 Homebrew安装,然后使用pip3 install pillow
. 碰巧,我已经安装了pip3
.
I've never understood the difference, if any, between installing a python package with pip
and installing it with Homebrew. Can you explain it to me? Also, is it preferable to install with Homebrew if a formula is available? If installing with Homebrew is indeed preferable, do you know how to install pillow
for python 3
with Homebrew?
我从来没有理解安装 python 包pip
和用 Homebrew 安装它之间的区别(如果有的话)。你能给我解释一下吗?另外,如果有可用的公式,是否最好与 Homebrew 一起安装?如果用自制安装的确是最好,你知道如何安装pillow
用于python 3
与自制?
The first answers indicate that I haven't made myself plain. If I had installed pillow with pip install pillow
instead of brew install pillow
would the installation on my system be any different? Why would Homebrew make a formula that does something that pip
already does? Would it check for additional prerequisites or something? Why is there a formula for pillow with python2
, but not as far as I can tell for pillow
with python3
?
第一个答案表明我没有让自己明白。如果我安装了枕头pip install pillow
而不是brew install pillow
我的系统上的安装会有什么不同吗?为什么 Homebrew 会制作一个可以做一些pip
已经做的事情的公式?它会检查额外的先决条件还是什么?为什么会出现与枕头的公式python2
,但并不至于我可以告诉大家的pillow
使用python3
?
采纳答案by uml?ute
well, packages for OSX may include packages for python.
好吧,OSX 的包可能包括 python 的包。
pip
is a packager for the python world - you should only ever be able to install python-things with it; homebrew
is a package manager targetted at OSX; it doesn't impose any restrictions onto what software you can install with it - since pythonis a subset of software.
pip
是 python 世界的打包器——你应该只能用它安装 python 东西;homebrew
是一个针对 OSX 的包管理器;它不会对您可以使用它安装的软件施加任何限制 - 因为python是software 的一个子集。
installing things with brew
will install them into /usr/local/
;
安装东西brew
会将它们安装到/usr/local/
;
installing things with pip
will fetch packages from the Python Package Index, and it will install them in a place where your python interpreter will find them: either into your home directory (e.g. ~/.local/lib/python2.7/site-packages/
) or in some global search-path of your python interpreter (e.g. /usr/local/lib/python2.7/dist-packages/
)
安装东西 withpip
将从Python Package Index 中获取包,并将它们安装在你的 python 解释器可以找到它们的地方:要么到你的主目录(例如~/.local/lib/python2.7/site-packages/
)或在你的 python 解释器的一些全局搜索路径中(例如/usr/local/lib/python2.7/dist-packages/
)
if you have installed the python
interpreter via brew
, then chances are high that any python-package installed via brew
will be usable out of the box.
如果您已经python
通过安装了解释器brew
,那么任何通过安装的 python 包brew
都可以开箱即用的可能性很高 。
回答by wpercy
Homebrew is a package manager, similar to apt
on ubuntu or yum
on some other linux distros. Pip is also a package manager, but is specific to python packages. Homebrew can be used to install a variety of things such as databases like MySQL and mongodb or webservers like apache or nginx.
Homebrew 是一个包管理器,类似于apt
ubuntu 或yum
其他一些 Linux 发行版。Pip 也是一个包管理器,但特定于 python 包。Homebrew 可用于安装各种东西,例如 MySQL 和 mongodb 等数据库或 apache 或 nginx 等网络服务器。
回答by Longwen Ou
I am also kind of confused about the differences between pip
-installed vs. brew
-installed python packages.
我也对pip
-installed 与brew
-installed python 包之间的差异感到困惑。
My understanding is that pip-installed package is not compiled for your specific system. It fetches the package from the the Python Package Indexthen compile and build it in your computer. Python package installed via homebrew
is already built and compiled for your specific system (Macos). They should both work. But I am not sure whether packages installed from the two ways will be put in the same location.
我的理解是 pip 安装的包不是为您的特定系统编译的。它从Python 包索引中获取包,然后在您的计算机中编译和构建它。通过安装的 Python 包homebrew
已经为您的特定系统 (Macos) 构建和编译。他们都应该工作。但我不确定从这两种方式安装的包是否会放在同一个位置。
For your questions about installing pillow
via homebrew
, I believe you should already done brew tap homebrew/python
, because that's how you can install python packages from homebrew
. On this github pagethey claim that
对于您关于pillow
通过安装的问题homebrew
,我相信您应该已经完成了brew tap homebrew/python
,因为这就是您可以从homebrew
. 在这个github 页面上,他们声称
Formula are installed with
Python 2
support by default. For simultaneousPython 3
support, usebrew install <formula> --with-python3
. If you don't needPython 2.x
support at all, you can pass--with-python3
--without-python
.
公式在
Python 2
默认情况下随支持安装。对于同时Python 3
支持,请使用brew install <formula> --with-python3
. 如果你根本不需要Python 2.x
支持,你可以通过--with-python3
--without-python
.
So try
所以试试
brew install pillow --with-python3
brew install pillow --with-python3
or
或者
brew install pillow --with-python3 --without-python
brew install pillow --with-python3 --without-python
if you only want to install pillow
for python3
. You may need to do brew uninstall pillow
first if homebrew
warns you that pillow
is already installed.
如果你只是想安装pillow
的python3
。brew uninstall pillow
如果homebrew
警告您pillow
已经安装,您可能需要先做。