macos Homebrew 使用 python 模块安装 libxml2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11054972/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 09:15:34  来源:igfitidea点击:

Homebrew install libxml2 with python modules

pythonmacoslibxml2homebrew

提问by Brandon

Good morning,

早上好,

I'm trying to install libxml2 with python modules. I have tried the following:

我正在尝试使用 python 模块安装 libxml2。我尝试了以下方法:

brew install --with-python libxml2                                                                  
==> Downloading ftp://xmlsoft.org/libxml2/libxml2-2.8.0.tar.gz
Already downloaded: /Users/brandon/Library/Caches/Homebrew/libxml2-2.8.0.tar.gz
==> ./configure --prefix=/usr/local/Cellar/libxml2/2.8.0 --without-python

As you can see... even with the --with-python flag, it is still configuring the source without python!

如您所见...即使使用 --with-python 标志,它仍然在不使用 python 的情况下配置源代码!

At the end of the install, homebrew says:

在安装结束时,自制软件说:

Generally there are no consequences of this for you.
If you build your own software and it requires this formula, you'll need
to add its lib & include paths to your build variables:

    LDFLAGS  -L/usr/local/Cellar/libxml2/2.8.0/lib
    CPPFLAGS -I/usr/local/Cellar/libxml2/2.8.0/include

When I try to install the gnome-doc-utils package:

当我尝试安装 gnome-doc-utils 包时:

Gnome-doc-utils requires libxml2 to be compiled
with the python modules enabled, to do so:
  $ brew install libxml2 --with-python

So obviously I tried again...

所以很明显我又试了一次......

╰─ brew install libxml2 --with-python
Error: libxml2-2.8.0 already installed

I'm still new to this... so any help would be greatly appreciated.

我还是个新手……所以任何帮助将不胜感激。

回答by kylehuff

First, you cannot install libxml2 because you already successfully installed it, so you will first need to uninstall it.

首先,您无法安装 libxml2,因为您已经成功安装了它,因此您首先需要卸载它。

brew uninstall libxml2

brew uninstall libxml2

Next you will need to edit the brew formula - which is simple enough to do --

接下来,您需要编辑冲煮公式 - 这很简单 -

type brew edit libxml2and change the line

键入 brew edit libxml2并更改行

system "./configure", "--prefix=#{prefix}", "--without-python"

to this:

对此:

system "./configure", "--prefix=#{prefix}", "--with-python"

This does not fix the problem with the brew formula, but it does force the flag "--with-python", so the next time you type brew install libxml2it will install the python libraries.

这并不能解决 brew 公式的问题,但它会强制使用标志“--with-python”,因此下次您键入brew install libxml2它时将安装 python 库。

If you need to reset the formula (undo your changes), simply type brew update

如果您需要重置公式(撤消更改),只需键入 brew update

回答by swbandit

This worked for me. First unlink/uninstall if done previously:

这对我有用。如果之前完成,请先取消链接/卸载:

brew unlink libxml2
brew unlink libxslt
brew uninstall libxml2
brew uninstall libxslt

Then

然后

brew install --framework python
brew install --with-python libxml2
brew install --with-python libxslt
brew link libxml2 --force
brew link libxslt --force

Voila!

瞧!

回答by slashmili

What worked for was installing libxml2 with --with-python in brew command

有用的是在 brew 命令中使用 --with-python 安装 libxml2

brew install --with-python libxml2

回答by Sebastian Ryszard Kruk

The answer from kylehunt let me fix an issue that some how started to show up after I ran "brew upgrade" after upgrading to macOS Catalina:

来自 kylehunt 的回答让我解决了在升级到 macOS Catalina 后运行“brew upgrade”后开始出现的一些问题:

If you happen to see things like

如果你碰巧看到类似的东西

Error: libxml2: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libxml2.rb:53: syntax error, unexpected <<
<<<<<<< Updated upstream
^~
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libxml2.rb:54: syntax error, unexpected ',', expecting end
...              "--with-history",
...                              ^
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libxml2.rb:55: syntax error, unexpected ',', expecting end
...            "--without-python",
...                              ^
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libxml2.rb:57: syntax error, unexpected ',', expecting end
...               "--with-python",
...

It means you should run

这意味着你应该跑

brew edit libxml2

To fix the config file as it might have been broken by merge conflicts during upgrade. Look for <<<<< in the file.

修复配置文件,因为它可能在升级过程中被合并冲突破坏。在文件中查找 <<<<<。