Can't Install xmlsec for Mac

3.4k views Asked by At

I'm new to django. i am tring to implement python3-saml which requires Xmlsec. i am trying to install it Using "pip install xmlsec" on my virtal environment. but throwing this error.

    Collecting xmlsec
    Using cached xmlsec-1.3.12.tar.gz (64 kB)
    Installing build dependencies ... done
    Getting requirements to build wheel ... done
    Installing backend dependencies ... done
    Preparing metadata (pyproject.toml) ... done
    Requirement already satisfied: lxml>=3.8 in 
    /opt/anaconda3/envs/conda_saml_env/lib/python3.10/site-packages (from xmlsec) 
    (4.8.0)
    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
    ╰─> [14 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)
  creating build
  creating build/lib.macosx-10.9-x86_64-3.10
  creating build/lib.macosx-10.9-x86_64-3.10/xmlsec
  copying src/xmlsec/py.typed -> build/lib.macosx-10.9-x86_64-3.10/xmlsec
  copying src/xmlsec/tree.pyi -> build/lib.macosx-10.9-x86_64-3.10/xmlsec
  copying src/xmlsec/__init__.pyi -> build/lib.macosx-10.9-x86_64-3.10/xmlsec
  copying src/xmlsec/constants.pyi -> build/lib.macosx-10.9-x86_64-3.10/xmlsec
  copying src/xmlsec/template.pyi -> build/lib.macosx-10.9-x86_64-3.10/xmlsec
  running build_ext
  error: xmlsec1 is not installed or not in path.
  [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 tried the following

  1. brew install libxml2 libxmlsec1 pkg-config

Output for above command is

Warning: libxml2 2.9.12 is already installed and up-to-date.
To reinstall 2.9.12, run:
   brew reinstall libxml2
Warning: libxmlsec1 1.2.33 is already installed and up-to-date.
To reinstall 1.2.33, 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

I got the same issue when i tried on Linux OS. Then i was able to solve this by running this command

sudo apt-get install libxmlsec1-dev

But i'm not able to run this command on my Mac. Is there anything i'm missing.

1

There are 1 answers

1
Aashish Kumar On

Use these Commands :

xcode-select --install
brew upgrade
brew install libxml2 libxmlsec1
pip install xmlsec