xmlsec not installing on mac

337 Views Asked by At

I'm trying to use pysaml2 to integrate AWS's SSO into my flask application, pysaml2 requires xmlsec, but I'm having trouble installing it.

Here the error im getting:

pip install xmlsec
Collecting xmlsec
  Using cached xmlsec-1.3.13.tar.gz (64 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: lxml>=3.8 in /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages (from xmlsec) (4.9.3)
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
  ╰─> [13 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.9-universal2-cpython-311
      creating build/lib.macosx-10.9-universal2-cpython-311/xmlsec
      copying src/xmlsec/py.typed -> build/lib.macosx-10.9-universal2-cpython-311/xmlsec
      copying src/xmlsec/tree.pyi -> build/lib.macosx-10.9-universal2-cpython-311/xmlsec
      copying src/xmlsec/__init__.pyi -> build/lib.macosx-10.9-universal2-cpython-311/xmlsec
      copying src/xmlsec/constants.pyi -> build/lib.macosx-10.9-universal2-cpython-311/xmlsec
      copying src/xmlsec/template.pyi -> build/lib.macosx-10.9-universal2-cpython-311/xmlsec
      running build_ext
      error: Unable to invoke pkg-config.
      [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

I have installed homebrew and installed libxml2, libxmlsec1, and pkg-config. However the issue is still there. Does anyone know a solution?

I've also tried solutions from other stack overflow questions, but they did not entirely match my case, and they did not work.

1

There are 1 best solutions below

0
Bimesh Perera On
  1. Check pkg-config Access: Ensure pkg-config is in your PATH.
 which pkg-config

If nothing returns, it's not in your PATH.

  1. Set PKG_CONFIG_PATH: Before installation, set the path:
 export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/opt/libxmlsec1/lib/pkgconfig"
 pip install xmlsec
  1. Direct Installation with Logging: Get a detailed error by installing directly from the source:
git clone https://github.com/mehcode/python-xmlsec.git
cd python-xmlsec
pip install -v .
  1. Use a Virtual Environment: Create an isolated Python environment and install within:
python -m venv myenv
source myenv/bin/activate
pip install xmlsec
  1. Install Compiler Tools:
xcode-select --install