简体   繁体   中英

How to install xmlsec on Windows? (pip install xmlsec fails)

The xmlsec docs suggest that pip install xmlsec should work right out of the box

Starting with 1.3.7, prebuilt wheels are available for Windows, so running pip install xmlsec should suffice.

However, this threw an error (see below).

I found this question , and I think the answers suggest I need to add native libraries pre-install. But since I'm on Windows and a bit of a beginner I don't know how to install packages like libxml2-dev, libxmlsec1-dev, or libxmlsec1-openssl. pip install libxml2-dev doesn't work and AFAIK I can't install brew on Windows. I have searched SO and Google extensively and just can't figure it out.

I also tried installing libxml2 separately by extracting some files from the bin folder and adding it to PATH as described here: https://pages.lip6.fr/Jean-Francois.Perrot/XML-Int/Session1/WinLibxml.html , but that didn't work either.

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`

The xmlsec docs suggest that pip install xmlsec should work right out of the box

They are referring to the fact, that they provide .whl files for windows. Which you can confirm if you check the pypi page . However, only python 3.5-3.9 are supported. If you are running pyhton 3.10, then a compilation from source is attempted.

It looks like xmlsec is downloading pre-built libraries from https://github.com/bgaifullin/libxml2-win-binaries/releases/ which cannot be linked with what your compiler creates on-the-fly (see your error message) because of a compiler version mismatch:

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

I think the easiest way around this would be to simply downgrade your python to 3.9 and then install with pip. Downloading/compiling your own version of the required libs would not solve the issue, since xmlsec always downloads the version it thinks it needs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM