我有一个BeagleBone黑板。操作系统是Debian GNU / Linux版本9.您可以使用HomeBrew安装Python吗?或者HomeBrew仅适用于Mac OS?
Homebrew仅适用于MacOS。
然而,Debian使用了apt,另一个包管理器,并且通过快速谷歌搜索看起来你的主板有它。
如果有一个版本的python可以工作,它应该可以通过像这样的命令安装
sudo apt-get update
sudo apt-get install python
对于python3:
sudo apt-get install python3
但是,完全有可能python已经与操作系统捆绑在一起,在这种情况下你不必安装python。要检查是否安装了/哪个版本的python,您可以执行以下操作:
python --version
或者对于python3:
python3 --version
在Linux上,您可以使用名为Linuxbrew的Homebrew的fork:
Homebrew包管理器可以在Linux和Windows 10上使用Windows子系统Linux(WSL)。在Linux或Windows上运行时,Homebrew被称为Linuxbrew。它可以安装在您的主目录中,在这种情况下它不使用sudo。
让我们从问题的最后一部分开始:
或者HomeBrew仅适用于Mac OS?
Stack Overflow的时间戳显示这个问题是在2019年3月7日被问到的。不久之前,一个合理的答案是,“是的,Homebrew用于macOS,但Linuxbrew是一个Homebrew的分支,它做了什么名字暗示:修改Homebrew以在Linux上工作“。
然而,在2019年2月2日 - 问题提出前一个多月 - Homebrew宣布版本2.0.0。在他们博客上的公告中,他们打开了这句话:
今天我想宣布Homebrew 2.0.0。自1.9.0以来最重大的变化是对Linux和Windows 10(使用Windows的Linux子系统)的官方支持,自动运行brew清理,Homebrew / homebrew-core中没有更多选项,以及删除对OS X Mountain Lion的支持(10.8) )和更老。
并进一步解释:
Linux上的Homebrew以前称为“Linuxbrew”。您可以将它安装在主目录中,因此它不需要sudo,并使用它来安装主机分发包管理器不提供的软件。 Linux上的Homebrew使用自己的公式库:Homebrew / linuxbrew-core
https://brew.sh/2019/02/02/homebrew-2.0.0/
然后,在2019年2月20日,README.md文件将此消息添加到Linuxbrew github存储库根目录下的README.md文件的顶部:
Linuxbrew has been merged into Homebrew
Linuxbrew / brew已合并到Homebrew/brew! Linuxbrew的现有安装将自动迁移到Homebrew。 Linuxbrew / brew将不再更新。请参阅Homebrew documentation of Linuxbrew和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合并回自制软件,它现在能运行良好吗?好吧,我面前有一个最新的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/
所以它安装了包,但是包是一个带有安装脚本的“包装器”,并且包仍然具有旧的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
来保存其文件。我们需要做的就是完成安装:
brew install gcc
。虽然他们要求您的操作系统提供大部分开发工具链,但他们显然已经决定要求您安装brew管理的编译器。这是有道理的,因为你的机器用来构建其他自制公式的编译器可能与他们在发布这些公式时正在测试的编译器同步。最初的问题还问:
你能用HomeBrew安装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提供的系统之上的系统。许多操作系统级实用程序依赖于apt管理的python安装,而Debian团队小心不要破坏它们。但也许你正在开发一些需要新功能的东西,只有最新的python版本才有。这就是Homebrew旨在解决的问题。
不,你不能使用HomeBrew在Debian Linux上安装,因为它只适用于MacO。
此外,python已经安装在Debian Linux发行版中,例如Ubuntu。但是,可以使用apt-get命令安装Linux发行版中的特定版本。我们可以使用apt-cache命令检查Python(预构建)可用包的名称。但是,这种安装其他Python版本的方式可能是潜在问题的根源(与最初安装的OS发行版本冲突)。因此请注意这一点。
$ apt-cache search python | less
$ sudo apt-get install pythonX.X
相反,最好继续安装所需的Python源代码。
有关如何从源代码安装的更多信息和说明,请访问以下链接:http://www.rasadacrea.com/en/web-training-courses/howto-install-python