HomeBrew 与 Debian GNU/Linux 兼容吗?
Is HomeBrew compatible with Debian GNU/Linux?
我有一块 BeagleBone Black 开发板。 OS 是 Debian GNU/Linux 版本 9。你可以使用 HomeBrew 安装 Python 吗?或者 HomeBrew 仅适用于 Mac OS?
Homebrew 仅适用于 MacOS。
Debian 使用 apt,但它是另一个包管理器,通过快速 google 搜索,您的主板似乎有它。
如果有可用的 python 版本,应该可以通过
这样的命令安装它
sudo apt-get update
sudo apt-get install python
对于 python3:
sudo apt-get install python3
但是,python 完全有可能已经与 OS 捆绑在一起,在这种情况下,您不必安装 python。要检查 if/what 版本的 python 是否已安装,您可以执行以下操作:
python --version
或 python3:
python3 --version
不,您不能使用 HomeBrew 在 Debian 上安装 Linux,因为它仅适用于 MacOs。
此外 python 已经安装在 Debian Linux 发行版中,例如 Ubuntu。但是,可以使用 apt-get 命令安装特定版本,可从 Linux 发行版获得。我们可以使用 apt-cache 命令检查 Python(预构建)可用包的名称。然而,这种安装额外 Python 版本的方式可能会成为潜在问题的来源(与 OS 发行版的原始安装版本冲突)。因此请注意这一点。
$ apt-cache search python | less
$ sudo apt-get install pythonX.X
相反,最好继续安装所需版本 Python 源代码。
有关如何从源安装的更多信息和说明,请遵循此 link:
http://www.rasadacrea.com/en/web-training-courses/howto-install-python
在 Linux 上,您可以使用名为 Linuxbrew:
的 Homebrew 分支
The Homebrew package manager may be used on Linux and Windows 10, using Windows Subsystem for Linux (WSL). Homebrew is referred to as Linuxbrew when running on Linux or Windows. It can be installed in your home directory, in which case it does not use sudo.
让我们从问题的最后一部分开始:
Or is HomeBrew only for Mac OS?
Stack Overflow 的时间戳显示这个问题是在 2019 年 3 月 7 日提出的。在此之前不久,一个合理的答案应该是,“是的,Homebrew 是为 macOS 而设计的,但是 Linuxbrew 是 Homebrew 的一个分支,顾名思义:修改 Homebrew 以在 Linux” 上工作。
然而,在 2019 年 2 月 2 日——在提出问题前一个多月——Homebrew 宣布了 2.0.0 版。在他们博客的公告中,他们以这样一句话开头:
Today I’d like to announce Homebrew 2.0.0. The most significant
changes since 1.9.0 are official support for Linux and Windows 10
(with Windows Subsystem for Linux), brew cleanup running
automatically, no more options in Homebrew/homebrew-core, and removal
of support for OS X Mountain Lion (10.8) and older.
并进一步解释:
Homebrew on Linux was previously called “Linuxbrew”. You can install
it in your home directory, so it does not require sudo, and use it to
install software that your host distribution’s package manager does
not provide. Homebrew on Linux uses its own repository for formulae:
Homebrew/linuxbrew-core
https://brew.sh/2019/02/02/homebrew-2.0.0/
然后,2019 年 2 月 20 日,README.md 文件将此消息添加到 Linuxbrew [=99= 根目录下的 README.md 文件顶部] 资料库:
Linuxbrew has been merged into Homebrew
Linuxbrew/brew has been merged into
Homebrew/brew! Existing
installations of Linuxbrew will be automatically migrated to Homebrew.
Linuxbrew/brew will no longer be updated. See the Homebrew
documentation of Linuxbrew and the
Homebrew 2.0.0 blog
post.
https://github.com/Linuxbrew/brew/pull/942/files
简而言之,是的。在这个问题发布前不久,Homebrew 正式支持Linux。 Debian GNU/Linux 版本 9,问题中提到的特定发行版,包含在其中。但是在您可以使用它来安装 python 之前,您很可能需要安装 Homebrew 本身,因为默认情况下它没有安装在 Debian 系统上。
Debian 9 甚至包含一个 'linuxbrew-wrapper' 软件包,它在 linuxbrew 被合并到 homebrew 之前就已经构建好了。
https://packages.debian.org/stretch/linuxbrew-wrapper
考虑到 linuxbrew 合并回 homebrew,它现在能正常工作吗?好吧,我面前有一个最新的 Debian 9 VM,让我们试一试吧:
$ sudo apt install linuxbrew-wrapper
[...]
The following additional packages will be installed:
fonts-lato libruby2.3 rake ruby ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert ruby-test-unit
ruby2.3 rubygems-integration zip
Suggested packages:
ri ruby-dev bundler
The following NEW packages will be installed:
fonts-lato libruby2.3 linuxbrew-wrapper rake ruby ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert
ruby-test-unit ruby2.3 rubygems-integration zip
0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,447 kB of archives.
After this operation, 27.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
[...]
$
所以现在安装了吗?让我们问一下 dpkg:
$ dpkg --status linuxbrew-wrapper
Package: linuxbrew-wrapper
Status: install ok installed
[...]
Description: Homebrew package manager for Linux
Linuxbrew is a fork of Homebrew, the Mac OS package manager, for Linux.
[...]
This package provides Linuxbrew install scripts instead of linuxbrew itself.
Homepage: http://linuxbrew.sh/
所以它安装了这个包,但是这个包是一个 'wrapper' 带有安装脚本,并且这个包仍然有旧的 linuxbrew 描述。如果我们尝试 运行 brew
会发生什么?
$ type brew
brew is /usr/bin/brew
$ brew
========================================================================
For the convenience of using linuxbrew it is recommended to update the
following environment variables after installing linuxbrew.
PATH, MANPATH, INFOPATH
Set HOMEBREW_BOTTLE_DOMAIN environment variable if you prefer some
homebrew mirror as your upstream.
(example: /usr/share/doc/linuxbrew-wrapper/examples/profile)
========================================================================
==> This script will install:
/home/parallels/.linuxbrew/bin/brew
/home/parallels/.linuxbrew/Library/...
/home/parallels/.linuxbrew/share/doc/homebrew
/home/parallels/.linuxbrew/share/man/man1/brew.1
/home/parallels/.linuxbrew/share/zsh/site-functions/_brew
/home/parallels/.linuxbrew/etc/bash_completion.d/brew
/home/parallels/.cache/Homebrew/
Press RETURN to continue or any other key to abort
==> Downloading and installing Linuxbrew...
[...]
==> Migrating from Linuxbrew/brew to Homebrew/brew
Linuxbrew/brew has been merged into Homebrew/brew!
Linuxbrew/brew will no longer be updated.
Your git remote has been changed from
https://github.com/Linuxbrew/brew
to https://github.com/Homebrew/brew
See the blog post at https://brew.sh/2019/02/02/homebrew-2.0.0/
Updating Homebrew...
[...]
==> Tapping homebrew/core
Cloning into '/home/parallels/.linuxbrew/Library/Taps/homebrew/homebrew-core'...
[...]
Warning: /home/parallels/.linuxbrew/bin is not in your PATH.
==> Installation successful!
==> Next steps
Install the Linuxbrew dependencies:
Debian, Ubuntu, etc.:
`sudo apt-get install build-essential`
Fedora, Red Hat, CentOS, etc.:
`sudo yum groupinstall 'Development Tools'`
See http://linuxbrew.sh/#dependencies for more information.
Add to your ~/.bash_profile by running
echo 'export PATH="/home/parallels/.linuxbrew/bin:$PATH"' >>~/.bash_profile
echo 'export MANPATH="/home/parallels/.linuxbrew/share/man:$MANPATH"' >>~/.bash_profile
echo 'export INFOPATH="/home/parallels/.linuxbrew/share/info:$INFOPATH"' >>~/.bash_profile
We recommend you install GCC by running `brew install gcc`.
Run `brew help` to get started
Further documentation: https://git.io/brew-docs
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here:
https://git.io/brew-analytics
Homebrew 2.0.6
Homebrew/linuxbrew-core (git revision 69e4; last commit 2019-03-31)
太棒了,它会自动更新自身以从 Linuxbrew 过渡到 Homebrew。值得注意的是,它仍然使用目录名称 ~/.linuxbrew
来保存其文件。我们需要做的就是完成安装:
安装安装输出中提到的任何 apt 依赖项。 Homebrew 从源代码构建东西,您的 Linux 发行版可以提供它想要的大部分开发工具链。
正在更新一些 'path' 环境变量。 Homebrew 正在为已安装的软件在文件系统上添加一个新位置,与 /bin 和 /usr/bin 等位置分开,因为 OS 包管理器管理这些目录的内容。将 Homebrew 的安装位置添加到这些路径可以找到 Hombrew 安装的软件。
brew install gcc
。虽然他们要求您的 OS 提供大部分开发工具链,但他们显然已经决定让您安装 brew 管理的编译器很重要。这是有道理的,因为你的机器用来构建其他自制公式的编译器可能会与他们在发布这些公式时正在测试的编译器同步。
原题还问:
Can you use HomeBrew to install Python?
让我们试试看:
$ brew install python
==> Installing dependencies for python: patchelf, pkg-config, gdbm, openssl, gpatch, ncurses, readline, sqlite, xz, bzip2, libffi and zlib
[...]
==> Installing python
==> Downloading https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
[...]
==> Caveats
Python has been installed as
/home/parallels/.linuxbrew/bin/python3
[...]
See: https://docs.brew.sh/Homebrew-and-Python
[...]
parallels@debian-gnu-linux-vm:~$
看起来你可以!
那么,当您可以使用 apt 完成时,为什么还要费心使用 Homebrew 来安装 python?嗯,围绕这样的问题进行了全面的讨论和辩论,但这是简短的答案...
apt安装的python:
$ /usr/bin/python3 --version
Python 3.5.3
自制软件安装的python:
$ ~/.linuxbrew/bin/python3 --version
Python 3.7.3
3.7.3 是我写这篇文章时的当前 python 版本。 Apt 管理的软件包按月或年的时间尺度更新。 Homebrew 管理的软件包按天或小时的时间范围更新。
为什么我们会看到 apt 和 homebrew 之间的巨大差异?将 homebrew 视为在 apt 提供的系统之上提供一个系统。许多 OS 级别的实用程序都依赖于 apt-managed python 安装,Debian 团队小心翼翼地避免破坏它们。但也许您正在做一些需要只有最新 python 版本才有的新功能的工作。这就是 Homebrew 旨在解决的问题。
我有一块 BeagleBone Black 开发板。 OS 是 Debian GNU/Linux 版本 9。你可以使用 HomeBrew 安装 Python 吗?或者 HomeBrew 仅适用于 Mac OS?
Homebrew 仅适用于 MacOS。
Debian 使用 apt,但它是另一个包管理器,通过快速 google 搜索,您的主板似乎有它。
如果有可用的 python 版本,应该可以通过
这样的命令安装它sudo apt-get update
sudo apt-get install python
对于 python3:
sudo apt-get install python3
但是,python 完全有可能已经与 OS 捆绑在一起,在这种情况下,您不必安装 python。要检查 if/what 版本的 python 是否已安装,您可以执行以下操作:
python --version
或 python3:
python3 --version
不,您不能使用 HomeBrew 在 Debian 上安装 Linux,因为它仅适用于 MacOs。
此外 python 已经安装在 Debian Linux 发行版中,例如 Ubuntu。但是,可以使用 apt-get 命令安装特定版本,可从 Linux 发行版获得。我们可以使用 apt-cache 命令检查 Python(预构建)可用包的名称。然而,这种安装额外 Python 版本的方式可能会成为潜在问题的来源(与 OS 发行版的原始安装版本冲突)。因此请注意这一点。
$ apt-cache search python | less
$ sudo apt-get install pythonX.X
相反,最好继续安装所需版本 Python 源代码。
有关如何从源安装的更多信息和说明,请遵循此 link: http://www.rasadacrea.com/en/web-training-courses/howto-install-python
在 Linux 上,您可以使用名为 Linuxbrew:
的 Homebrew 分支The Homebrew package manager may be used on Linux and Windows 10, using Windows Subsystem for Linux (WSL). Homebrew is referred to as Linuxbrew when running on Linux or Windows. It can be installed in your home directory, in which case it does not use sudo.
让我们从问题的最后一部分开始:
Or is HomeBrew only for Mac OS?
Stack Overflow 的时间戳显示这个问题是在 2019 年 3 月 7 日提出的。在此之前不久,一个合理的答案应该是,“是的,Homebrew 是为 macOS 而设计的,但是 Linuxbrew 是 Homebrew 的一个分支,顾名思义:修改 Homebrew 以在 Linux” 上工作。
然而,在 2019 年 2 月 2 日——在提出问题前一个多月——Homebrew 宣布了 2.0.0 版。在他们博客的公告中,他们以这样一句话开头:
Today I’d like to announce Homebrew 2.0.0. The most significant changes since 1.9.0 are official support for Linux and Windows 10 (with Windows Subsystem for Linux), brew cleanup running automatically, no more options in Homebrew/homebrew-core, and removal of support for OS X Mountain Lion (10.8) and older.
并进一步解释:
Homebrew on Linux was previously called “Linuxbrew”. You can install it in your home directory, so it does not require sudo, and use it to install software that your host distribution’s package manager does not provide. Homebrew on Linux uses its own repository for formulae: Homebrew/linuxbrew-core
https://brew.sh/2019/02/02/homebrew-2.0.0/
然后,2019 年 2 月 20 日,README.md 文件将此消息添加到 Linuxbrew [=99= 根目录下的 README.md 文件顶部] 资料库:
Linuxbrew has been merged into Homebrew
Linuxbrew/brew has been merged into Homebrew/brew! Existing installations of Linuxbrew will be automatically migrated to Homebrew. Linuxbrew/brew will no longer be updated. See the Homebrew documentation of Linuxbrew and the Homebrew 2.0.0 blog post.
https://github.com/Linuxbrew/brew/pull/942/files
简而言之,是的。在这个问题发布前不久,Homebrew 正式支持Linux。 Debian GNU/Linux 版本 9,问题中提到的特定发行版,包含在其中。但是在您可以使用它来安装 python 之前,您很可能需要安装 Homebrew 本身,因为默认情况下它没有安装在 Debian 系统上。
Debian 9 甚至包含一个 'linuxbrew-wrapper' 软件包,它在 linuxbrew 被合并到 homebrew 之前就已经构建好了。
https://packages.debian.org/stretch/linuxbrew-wrapper
考虑到 linuxbrew 合并回 homebrew,它现在能正常工作吗?好吧,我面前有一个最新的 Debian 9 VM,让我们试一试吧:
$ sudo apt install linuxbrew-wrapper
[...]
The following additional packages will be installed:
fonts-lato libruby2.3 rake ruby ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert ruby-test-unit
ruby2.3 rubygems-integration zip
Suggested packages:
ri ruby-dev bundler
The following NEW packages will be installed:
fonts-lato libruby2.3 linuxbrew-wrapper rake ruby ruby-did-you-mean ruby-minitest ruby-net-telnet ruby-power-assert
ruby-test-unit ruby2.3 rubygems-integration zip
0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,447 kB of archives.
After this operation, 27.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
[...]
$
所以现在安装了吗?让我们问一下 dpkg:
$ dpkg --status linuxbrew-wrapper
Package: linuxbrew-wrapper
Status: install ok installed
[...]
Description: Homebrew package manager for Linux
Linuxbrew is a fork of Homebrew, the Mac OS package manager, for Linux.
[...]
This package provides Linuxbrew install scripts instead of linuxbrew itself.
Homepage: http://linuxbrew.sh/
所以它安装了这个包,但是这个包是一个 'wrapper' 带有安装脚本,并且这个包仍然有旧的 linuxbrew 描述。如果我们尝试 运行 brew
会发生什么?
$ type brew
brew is /usr/bin/brew
$ brew
========================================================================
For the convenience of using linuxbrew it is recommended to update the
following environment variables after installing linuxbrew.
PATH, MANPATH, INFOPATH
Set HOMEBREW_BOTTLE_DOMAIN environment variable if you prefer some
homebrew mirror as your upstream.
(example: /usr/share/doc/linuxbrew-wrapper/examples/profile)
========================================================================
==> This script will install:
/home/parallels/.linuxbrew/bin/brew
/home/parallels/.linuxbrew/Library/...
/home/parallels/.linuxbrew/share/doc/homebrew
/home/parallels/.linuxbrew/share/man/man1/brew.1
/home/parallels/.linuxbrew/share/zsh/site-functions/_brew
/home/parallels/.linuxbrew/etc/bash_completion.d/brew
/home/parallels/.cache/Homebrew/
Press RETURN to continue or any other key to abort
==> Downloading and installing Linuxbrew...
[...]
==> Migrating from Linuxbrew/brew to Homebrew/brew
Linuxbrew/brew has been merged into Homebrew/brew!
Linuxbrew/brew will no longer be updated.
Your git remote has been changed from
https://github.com/Linuxbrew/brew
to https://github.com/Homebrew/brew
See the blog post at https://brew.sh/2019/02/02/homebrew-2.0.0/
Updating Homebrew...
[...]
==> Tapping homebrew/core
Cloning into '/home/parallels/.linuxbrew/Library/Taps/homebrew/homebrew-core'...
[...]
Warning: /home/parallels/.linuxbrew/bin is not in your PATH.
==> Installation successful!
==> Next steps
Install the Linuxbrew dependencies:
Debian, Ubuntu, etc.:
`sudo apt-get install build-essential`
Fedora, Red Hat, CentOS, etc.:
`sudo yum groupinstall 'Development Tools'`
See http://linuxbrew.sh/#dependencies for more information.
Add to your ~/.bash_profile by running
echo 'export PATH="/home/parallels/.linuxbrew/bin:$PATH"' >>~/.bash_profile
echo 'export MANPATH="/home/parallels/.linuxbrew/share/man:$MANPATH"' >>~/.bash_profile
echo 'export INFOPATH="/home/parallels/.linuxbrew/share/info:$INFOPATH"' >>~/.bash_profile
We recommend you install GCC by running `brew install gcc`.
Run `brew help` to get started
Further documentation: https://git.io/brew-docs
==> Homebrew has enabled anonymous aggregate user behaviour analytics
Read the analytics documentation (and how to opt-out) here:
https://git.io/brew-analytics
Homebrew 2.0.6
Homebrew/linuxbrew-core (git revision 69e4; last commit 2019-03-31)
太棒了,它会自动更新自身以从 Linuxbrew 过渡到 Homebrew。值得注意的是,它仍然使用目录名称 ~/.linuxbrew
来保存其文件。我们需要做的就是完成安装:
安装安装输出中提到的任何 apt 依赖项。 Homebrew 从源代码构建东西,您的 Linux 发行版可以提供它想要的大部分开发工具链。
正在更新一些 'path' 环境变量。 Homebrew 正在为已安装的软件在文件系统上添加一个新位置,与 /bin 和 /usr/bin 等位置分开,因为 OS 包管理器管理这些目录的内容。将 Homebrew 的安装位置添加到这些路径可以找到 Hombrew 安装的软件。
brew install gcc
。虽然他们要求您的 OS 提供大部分开发工具链,但他们显然已经决定让您安装 brew 管理的编译器很重要。这是有道理的,因为你的机器用来构建其他自制公式的编译器可能会与他们在发布这些公式时正在测试的编译器同步。
原题还问:
Can you use HomeBrew to install Python?
让我们试试看:
$ brew install python
==> Installing dependencies for python: patchelf, pkg-config, gdbm, openssl, gpatch, ncurses, readline, sqlite, xz, bzip2, libffi and zlib
[...]
==> Installing python
==> Downloading https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
[...]
==> Caveats
Python has been installed as
/home/parallels/.linuxbrew/bin/python3
[...]
See: https://docs.brew.sh/Homebrew-and-Python
[...]
parallels@debian-gnu-linux-vm:~$
看起来你可以!
那么,当您可以使用 apt 完成时,为什么还要费心使用 Homebrew 来安装 python?嗯,围绕这样的问题进行了全面的讨论和辩论,但这是简短的答案...
apt安装的python:
$ /usr/bin/python3 --version
Python 3.5.3
自制软件安装的python:
$ ~/.linuxbrew/bin/python3 --version
Python 3.7.3
3.7.3 是我写这篇文章时的当前 python 版本。 Apt 管理的软件包按月或年的时间尺度更新。 Homebrew 管理的软件包按天或小时的时间范围更新。
为什么我们会看到 apt 和 homebrew 之间的巨大差异?将 homebrew 视为在 apt 提供的系统之上提供一个系统。许多 OS 级别的实用程序都依赖于 apt-managed python 安装,Debian 团队小心翼翼地避免破坏它们。但也许您正在做一些需要只有最新 python 版本才有的新功能的工作。这就是 Homebrew 旨在解决的问题。