无法通过pip安装xmlsec。

huangapple go评论122阅读模式
英文:

Can't install xmlsec via pip

问题

在 macOS 上安装 xmlsec 时出现了错误。要解决这个问题,你可以尝试以下步骤:

  1. 升级 pip 版本:错误消息中建议你升级 pip 的版本。你可以运行以下命令来升级 pip:

    /Users/davidmasip/.pyenv/versions/3.9.9/bin/python3.9 -m pip install --upgrade pip
    
  2. 安装依赖项:确保你已经安装了 libxml2libxmlsec1pkg-configxz。根据你的信息,这些依赖项似乎已经安装并且是最新的,所以不需要重复安装它们。

  3. 检查 Python 版本:确保你正在使用正确的 Python 版本。你在 /Users/davidmasip/.pyenv/versions/3.9.9/bin/python3.9 中使用 Python 3.9.9,但你也可以尝试使用系统默认的 Python 版本。

  4. 查看是否有更新的 xmlsec 版本:可能有新的 xmlsec 版本已经发布,修复了与 macOS Big Sur 11.3.1 兼容性的问题。你可以查看 xmlsec 的官方网站或仓库,看是否有新的版本可供下载。

  5. 考虑使用虚拟环境:如果你使用虚拟环境管理 Python 环境,确保你在正确的虚拟环境中运行 pip 安装命令。

尝试上述步骤中的一个或多个,以解决在 macOS 上安装 xmlsec 时遇到的问题。如果问题仍然存在,请提供更多详细信息,以便更好地帮助你解决问题。

英文:

I'm getting the following when running pip install xmlsec in macOS Big Sur 11.3.1:

Building wheels for collected packages: xmlsec
  Building wheel for xmlsec (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/davidmasip/.pyenv/versions/3.9.9/bin/python3.9 /Users/davidmasip/.pyenv/versions/3.9.9/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/tmpm51b1yso
       cwd: /private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d
  Complete output (65 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-11.3-x86_64-cpython-39
  creating build/lib.macosx-11.3-x86_64-cpython-39/xmlsec
  copying src/xmlsec/py.typed -> build/lib.macosx-11.3-x86_64-cpython-39/xmlsec
  copying src/xmlsec/tree.pyi -> build/lib.macosx-11.3-x86_64-cpython-39/xmlsec
  copying src/xmlsec/__init__.pyi -> build/lib.macosx-11.3-x86_64-cpython-39/xmlsec
  copying src/xmlsec/constants.pyi -> build/lib.macosx-11.3-x86_64-cpython-39/xmlsec
  copying src/xmlsec/template.pyi -> build/lib.macosx-11.3-x86_64-cpython-39/xmlsec
  running build_ext
  building 'xmlsec' extension
  creating build/temp.macosx-11.3-x86_64-cpython-39
  creating build/temp.macosx-11.3-x86_64-cpython-39/private
  creating build/temp.macosx-11.3-x86_64-cpython-39/private/var
  creating build/temp.macosx-11.3-x86_64-cpython-39/private/var/folders
  creating build/temp.macosx-11.3-x86_64-cpython-39/private/var/folders/ff
  creating build/temp.macosx-11.3-x86_64-cpython-39/private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp
  creating build/temp.macosx-11.3-x86_64-cpython-39/private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T
  creating build/temp.macosx-11.3-x86_64-cpython-39/private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud
  creating build/temp.macosx-11.3-x86_64-cpython-39/private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d
  creating build/temp.macosx-11.3-x86_64-cpython-39/private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d/src
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_FTP=1 -DXMLSEC_NO_MD5=1 -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_CRYPTO_OPENSSL=1 -DMODULE_NAME=xmlsec -DMODULE_VERSION=1.3.13 -I/usr/local/Cellar/libxmlsec1/1.3.0/include/xmlsec1 -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/openssl@1.1/include/openssl -I/private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-build-env-gsnsoluq/overlay/lib/python3.9/site-packages/lxml/includes -I/private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-build-env-gsnsoluq/overlay/lib/python3.9/site-packages/lxml -I/private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-build-env-gsnsoluq/overlay/lib/python3.9/site-packages/lxml/includes/libxml -I/private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-build-env-gsnsoluq/overlay/lib/python3.9/site-packages/lxml/includes/libxslt -I/private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-build-env-gsnsoluq/overlay/lib/python3.9/site-packages/lxml/includes/libexslt -I/private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-build-env-gsnsoluq/overlay/lib/python3.9/site-packages/lxml/includes/extlibs -I/private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-build-env-gsnsoluq/overlay/lib/python3.9/site-packages/lxml/includes/__pycache__ -I/Users/davidmasip/.pyenv/versions/3.9.9/include/python3.9 -c /private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d/src/constants.c -o build/temp.macosx-11.3-x86_64-cpython-39/private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d/src/constants.o -g -std=c99 -fPIC -fno-strict-aliasing -Wno-error=declaration-after-statement -Werror=implicit-function-declaration -Os
  /private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d/src/constants.c:319:5: error: use of undeclared identifier 'xmlSecSoap11Ns'
      PYXMLSEC_ADD_NS_CONSTANT(Soap11Ns, "SOAP11");
      ^
  /private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d/src/constants.c:304:46: note: expanded from macro 'PYXMLSEC_ADD_NS_CONSTANT'
      tmp = PyUnicode_FromString((const char*)(JOIN(xmlSec, name))); \
                                               ^
  /private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d/src/common.h:19:19: note: expanded from macro 'JOIN'
  #define JOIN(X,Y) DO_JOIN1(X,Y)
                    ^
  /private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d/src/common.h:20:23: note: expanded from macro 'DO_JOIN1'
  #define DO_JOIN1(X,Y) DO_JOIN2(X,Y)
                        ^
  /private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d/src/common.h:21:23: note: expanded from macro 'DO_JOIN2'
  #define DO_JOIN2(X,Y) X##Y
                        ^
  <scratch space>:23:1: note: expanded from here
  xmlSecSoap11Ns
  ^
  /private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d/src/constants.c:320:5: error: use of undeclared identifier 'xmlSecSoap12Ns'; did you mean 'xmlSecXPath2Ns'?
      PYXMLSEC_ADD_NS_CONSTANT(Soap12Ns, "SOAP12");
      ^
  /private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d/src/constants.c:304:46: note: expanded from macro 'PYXMLSEC_ADD_NS_CONSTANT'
      tmp = PyUnicode_FromString((const char*)(JOIN(xmlSec, name))); \
                                               ^
  /private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d/src/common.h:19:19: note: expanded from macro 'JOIN'
  #define JOIN(X,Y) DO_JOIN1(X,Y)
                    ^
  /private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d/src/common.h:20:23: note: expanded from macro 'DO_JOIN1'
  #define DO_JOIN1(X,Y) DO_JOIN2(X,Y)
                        ^
  /private/var/folders/ff/3y2196b13bq0nbm3_ms25nyh0000gp/T/pip-install-qm2a1dud/xmlsec_cd7a81ea26444cc4b8ae24acd3ec379d/src/common.h:21:23: note: expanded from macro 'DO_JOIN2'
  #define DO_JOIN2(X,Y) X##Y
                        ^
  <scratch space>:25:1: note: expanded from here
  xmlSecSoap12Ns
  ^
  /usr/local/Cellar/libxmlsec1/1.3.0/include/xmlsec1/xmlsec/strings.h:34:33: note: 'xmlSecXPath2Ns' declared here
  XMLSEC_EXPORT_VAR const xmlChar xmlSecXPath2Ns[];
                                  ^
  2 errors generated.
  error: command '/usr/bin/clang' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for xmlsec
Failed to build xmlsec
ERROR: Could not build wheels for xmlsec which use PEP 517 and cannot be installed directly
WARNING: You are using pip version 21.2.4; however, version 23.0.1 is available.
You should consider upgrading via the '/Users/davidmasip/.pyenv/versions/3.9.9/bin/python3.9 -m pip install --upgrade pip' command.

I've also run before:

brew install libxml2 libxmlsec1 pkg-config xz

And I get:

Warning: libxml2 2.10.4 is already installed and up-to-date.
To reinstall 2.10.4, run:
  brew reinstall libxml2
Warning: libxmlsec1 1.3.0 is already installed and up-to-date.
To reinstall 1.3.0, run:
  brew reinstall libxmlsec1
Warning: pkg-config 0.29.2_3 is already installed and up-to-date.
To reinstall 0.29.2_3, run:
  brew reinstall pkg-config
Warning: xz 5.4.2 is already installed and up-to-date.
To reinstall 5.4.2, run:
  brew reinstall xz

how can I install xmlsec in macOS?

答案1

得分: 27

这个GitHub评论是最简单的修复。

libxmlsec1 升级到 v1.3 时,它破坏了 pip install xmlsec

我正在使用一台装有 Apple Silicon(M1 / M2)的Macbook,一直在寻找解决方法。

我通过 @dpritchett这个评论 中的Homebrew公式hack成功解决了这个问题:

  1. brew edit libxmlsec1。编辑器打开,显示了最新下载的来自GitHub或其他地方的 xmlsec 公式的内容。
  2. 我粘贴了上一个版本的 brew 公式 的内容,然后保存。
  3. 安装本地公式:brew install /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libxmlsec1.rb
  4. pip install xmlsec

有关依赖于您的Homebrew版本的解决方法的其他信息,请参见下方的评论和GitHub问题的评论。

我已完成翻译,请提供更多内容或指令。

英文:

EDIT

This GitHub comment is the simplest fix.

> https://github.com/xmlsec/python-xmlsec/issues/254#issuecomment-1612005910


When libxmlsec1 was bumped to v1.3 it broke pip install xmlsec.

> https://github.com/xmlsec/python-xmlsec/issues/254

I am using a Macbook with Apple Silicon (M1 / M2) and struggled for a while to find this.

I managed to workaround it via the Homebrew formula hack in this comment by @dpritchett:

> https://raw.githubusercontent.com/Homebrew/homebrew-core/7f35e6ede954326a10949891af2dba47bbe1fc17/Formula/libxmlsec1.rb
>
> Specific workaround steps:
>
> 1. brew edit libxmlsec1. An editor opens up, full of the contents of the latest downloaded xmlsec formula from GitHub or wherever they come from
> 2. i paste in the contents of the last pre-1.3.0 brew formula
> and hit save
> 3. Install that local formula: brew install /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/libxmlsec1.rb
> 4. pip install xmlsec

EDIT

See comments below and comments on GitHub issue for additional info about the workaround that depend on your version of homebrew.

> https://github.com/xmlsec/python-xmlsec/issues/254#issuecomment-1522646438

答案2

得分: 8

以下是翻译好的部分:

有另一种安装较早版本的libxmlsec1的方法,不涉及brew edit由D3X编写

一个“更好”的(更干净的)解决方法是创建一个本地 tap 并提取以前的版本,如下所示:

brew tap-new $USER/local
brew extract --version=1.2.37 libxmlsec1 $USER/local
brew uninstall libxmlsec1
brew install $USER/local/libxmlsec1@1.2.37

一旦 python-xmlsec 更新以支持 libxmlsec1 1.3+,您可以通过以下方式卸载提取的版本并删除 tap:

brew uninstall $USER/local/libxmlsec1@1.2.37
brew untap $USER/local
英文:

There's another way to install an earlier version of libxmlsec1 that doesn't involve brew edit, written by D3X.

> A "better" (cleaner) workaround is to create a local tap and extract the previous version, like so:
>

brew tap-new $USER/local
brew extract --version=1.2.37 libxmlsec1 $USER/local
brew uninstall libxmlsec1
brew install $USER/local/libxmlsec1@1.2.37

> Once python-xmlsec is updated to support libxmlsec1 1.3+, you can uninstall the extracted version and remove the tap by doing:

brew uninstall $USER/local/libxmlsec1@1.2.37
brew untap $USER/local

答案3

得分: 2

Answer by @Dag Høidahl 几乎适用于我。但是以下命令:

brew install $USER/local/libxmlsec1@1.2.37


命令失败,出现404错误:

Error: libxmlsec1@1.2.37: Failed to download resource "libxmlsec1@1.2.37"
Failure while executing; /usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.0.28-7-gcb61785\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.4.1\)\ curl/7.88.1 --header Accept-Language:\ en --retry 3 --fail --location --silent --head --request GET https://www.aleksey.com/xmlsec/download/xmlsec1-1.2.37.tar.gz exited with 22. Here's the output:
curl: (22) The requested URL returned error: 404
HTTP/1.1 404 Not Found
...


我不得不手动修补公式才能使其正常工作。我从以下命令获取了公式的路径:

brew extract --version=1.2.37 libxmlsec1 $USER/local
==> Searching repository history
==> Writing formula for libxmlsec1 from revision 17a2c4d to:
/opt/homebrew/Library/Taps/user/homebrew-local/Formula/libxmlsec1@1.2.37.rb # <- 公式的路径


然后我更新了文件并替换了以下行:

url "https://www.aleksey.com/xmlsec/download/xmlsec1-1.2.37.tar.gz"


替换为:

url "https://www.aleksey.com/xmlsec/download/older-releases/xmlsec1-1.2.37.tar.gz"


所以接着运行`brew install $USER/local/libxmlsec1@1.2.37`就可以正常工作了。
英文:

Answer by @Dag Høidahl almost worked for me. However the:

brew install $USER/local/libxmlsec1@1.2.37

command failed with 404 error:

Error: libxmlsec1@1.2.37: Failed to download resource &quot;libxmlsec1@1.2.37&quot;
Failure while executing; `/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.0.28-7-gcb61785\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.4.1\)\ curl/7.88.1 --header Accept-Language:\ en --retry 3 --fail --location --silent --head --request GET https://www.aleksey.com/xmlsec/download/xmlsec1-1.2.37.tar.gz` exited with 22. Here&#39;s the output:
curl: (22) The requested URL returned error: 404
HTTP/1.1 404 Not Found
...

I had to manually patch the formula for it to work. I got the path to the formula from this command:

brew extract --version=1.2.37 libxmlsec1 $USER/local
==&gt; Searching repository history
==&gt; Writing formula for libxmlsec1 from revision 17a2c4d to:
/opt/homebrew/Library/Taps/user/homebrew-local/Formula/libxmlsec1@1.2.37.rb # &lt;- path to the formula

I then updated the file and replaced the following line:

url &quot;https://www.aleksey.com/xmlsec/download/xmlsec1-1.2.37.tar.gz&quot;

with:

url &quot;https://www.aleksey.com/xmlsec/download/older-releases/xmlsec1-1.2.37.tar.gz&quot;

So then rerunning brew install $USER/local/libxmlsec1@1.2.37 worked fine.

答案4

得分: 1

由于python-xmlsec尚未更新以支持libxmlsec1@1.3,因此创建一个本地的libxmlsec1@1.2.37 tap并安装它仍然是解决此问题的最干净的方法。然而,我在使用@Dag Høidahl提到的解决方案时遇到了一些问题。

  1. 在运行brew tap-new $USER/local时出现“无效的tap名称”。因为我的$USER中包含了一个.,使它成为无效的tap名称,所以我不得不手动设置一个名称。
  2. 在运行brew install $USER/local/libxmlsec1@1.2.37时,出现了“curl: (22) 请求的URL返回错误:404”。随着版本1.2.38的发布,brew下载的xmlsec tarball已移动到older-releases目录,因此我需要在libxmlsec1.rb文件中更改URL。

以下是适用于我的更新版本:

MYNAME=neruson
brew tap-new $MYNAME/local
brew extract --version=1.2.37 libxmlsec1 $MYNAME/local
sed -i '' 's^/xmlsec/download/^/xmlsec/download/older-releases/^g' /opt/homebrew/Library/Taps/$MYNAME/homebrew-local/Formula/libxmlsec1@1.2.37.rb
brew uninstall libxmlsec1
brew install $MYNAME/local/libxmlsec1@1.2.37
英文:

Since python-xmlsec hasn't been updated to support libxmlsec1@1.3, creating a local tap of libxmlsec1@1.2.37 and installing it is still the cleanest workaround for the issue. However, I ran into a few issues while using the solution mentioned by @Dag Høidahl.

  1. Invalid tap name when running brew tap-new $USER/local My $USER has a . in it, making it an invalid tap name, so I had to manually set a name.
  2. curl: (22) The requested URL returned error: 404 when running brew install $USER/local/libxmlsec1@1.2.37. The xmlsec tarball that brew downloads has moved into the older-releases directory with the release of version 1.2.38, so I needed to change the URL in the libxmlsec1.rb file.

This is an updated version that worked for me:

MYNAME=neruson
brew tap-new $MYNAME/local
brew extract --version=1.2.37 libxmlsec1 $MYNAME/local
sed -i &#39;&#39; &#39;s^/xmlsec/download/^/xmlsec/download/older-releases/^g&#39; /opt/homebrew/Library/Taps/$MYNAME/homebrew-local/Formula/libxmlsec1@1.2.37.rb
brew uninstall libxmlsec1
brew install $MYNAME/local/libxmlsec1@1.2.37

huangapple
  • 本文由 发表于 2023年4月13日 20:24:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76005401.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定