【问题标题】:How to install xmlsec on Windows? (pip install xmlsec fails)如何在 Windows 上安装 xmlsec? (pip install xmlsec 失败)
【发布时间】:2022-02-03 17:55:53
【问题描述】:

xmlsec docs 建议 pip install xmlsec 应该开箱即用

从 1.3.7 开始,预构建的轮子可用于 Windows,因此运行 pip install xmlsec 就足够了。

但是,这引发了错误(见下文)。

我找到了this question,我认为答案表明我需要预先安装本机库。但由于我在 Windows 上并且有点初学者,我不知道如何安装 libxml2-dev、libxmlsec1-dev 或 libxmlsec1-openssl 等软件包。 pip install libxml2-dev 不起作用,我无法在 Windows 上安装 brew。我已经广泛搜索了 SO 和 Google,但无法弄清楚。

我还尝试通过从 bin 文件夹中提取一些文件并将其添加到 PATH 中来单独安装 libxml2,如下所述:https://pages.lip6.fr/Jean-Francois.Perrot/XML-Int/Session1/WinLibxml.html,但这也不起作用。

Building wheels for collected packages: xmlsec
  Building wheel for xmlsec (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for xmlsec (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [62 lines of output]
      running bdist_wheel
      running build
      running build_py
      package init file 'src\xmlsec\__init__.py' not found (or not a regular file)
      running build_ext
      building 'xmlsec' extension
      constants.c

      ...LOTS OF ERRORS/WARNINGS...

      fatal error C1047: The object or library file 'C:\Users\12345\AppData\Local\Temp\pip-install-3tfgg6bc\xmlsec_12345\build\tmp\libs\iconv-1.14.win64\lib\iconv_a.lib' was created with an older compiler than other objects; rebuild old objects and libraries
      LINK : fatal error LNK1257: code generation failed
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\link.exe' failed with exit code 1257
      [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for xmlsec
Failed to build xmlsec
ERROR: Could not build wheels for xmlsec, which is required to install pyproject.toml-based projects`

【问题讨论】:

    标签: python windows pip command-line-interface


    【解决方案1】:

    xmlsec 文档建议 pip install xmlsec 应该开箱即用

    他们指的是这样一个事实,即他们为 Windows 提供 .whl 文件。如果您check the pypi page,您可以确认。但是,仅支持 python 3.5-3.9。如果您运行的是 pyhton 3.10,则会尝试从源代码编译。

    看起来 xmlsec 正在从 https://github.com/bgaifullin/libxml2-win-binaries/releases/ 下载预构建的库,由于编译器版本不匹配,这些库无法与您的编译器即时创建的库链接(请参阅您的错误消息):

    fatal error C1047: The object or library file 'C:\Users\12345\AppData\Local\Temp\pip-install-3tfgg6bc\xmlsec_12345\build\tmp\libs\iconv-1.14.win64\lib\iconv_a.lib' was created with an older compiler than other objects; rebuild old objects and libraries
    

    我认为解决此问题的最简单方法是将 python 降级到 3.9,然后使用 pip 安装。下载/编译您自己的所需库版本并不能解决问题,因为xmlsec 总是下载它认为需要的版本

    【讨论】:

    • 谢谢,我错过了检查版本。
    猜你喜欢
    • 1970-01-01
    • 2020-12-30
    • 2012-09-20
    • 1970-01-01
    • 1970-01-01
    • 2019-02-22
    • 1970-01-01
    • 1970-01-01
    • 2019-10-31
    相关资源
    最近更新 更多