python-xmlsec: import xmlsec fails on python 3.8/3.9, macOS Big Sur 11.0.1 and M1 chip
xmlsec version: 1.3.9
libxmlsec1 version: 1.2.31
libxml2 version: 2.9.10_2
(venv) tesh$ pkg-config --cflags xmlsec1
-D__XMLSEC_FUNCTION__=__func__ -DXMLSEC_NO_SIZE_T -DXMLSEC_NO_GOST=1 -DXMLSEC_NO_GOST2012=1 -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_CRYPTO_OPENSSL=1 -I/opt/homebrew/Cellar/libxmlsec1/1.2.31/include/xmlsec1 -I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/openssl@1.1/include/openssl
It installs fine but fails when importing.
In [1]: import xmlsec
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-43dd76db73dd> in <module>
----> 1 import xmlsec
ImportError: dlopen(/Users/tesh/rescale/venv3.9/lib/python3.9/site-packages/xmlsec.cpython-39-darwin.so, 2): Symbol not found: _xmlSecDSigNs
Referenced from: /Users/tesh/rescale/venv3.9/lib/python3.9/site-packages/xmlsec.cpython-39-darwin.so
Expected in: flat namespace
in /Users/tesh/rescale/venv3.9/lib/python3.9/site-packages/xmlsec.cpython-39-darwin.so
Python 3.8 and 3.9
$ file $(which python)
/Users/tesh/rescale/venv/bin/python: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
/Users/tesh/rescale/venv/bin/python (for architecture x86_64): Mach-O 64-bit executable x86_64
/Users/tesh/rescale/venv/bin/python (for architecture arm64): Mach-O 64-bit executable arm64
$ file $(which python)
/Users/tesh/rescale/venv3.9/bin/python: Mach-O 64-bit executable x86_64
$ otool -L /Users/tesh/rescale/venv3.9/lib/python3.9/site-packages/xmlsec.cpython-39-darwin.so
/Users/tesh/rescale/venv3.9/lib/python3.9/site-packages/xmlsec.cpython-39-darwin.so:
/usr/lib/libxslt.1.dylib (compatibility version 3.0.0, current version 3.26.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
/usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 66.1.0)
Will really appreciate any help.
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 37 (4 by maintainers)
I issued with
xmlsec.cpython-313-darwin.so, 0x0002): symbol not found in flat namespace '_xmlSecOpenSSLTransformHmacRipemd160GetKlass'I have Python 3.13 and macos M1. For me helped next steps:
uv remove xmlsec;uv pip install --no-binary :all: xmlsecI use
uvtool but I think it works for pip and poetry tooHi there, are there any plans on progressing on this issue anytime soon? I understand the constraints, and would just like to get some feedback so that we can plan for alternatives if needed.
I too have found this very same issue, any fix for this ?
You can see it if you do
pip install -v --no-cache-dir xmlsec. I was able to solve this issue for one of my devs today by installing python, libxml2, libxmlsec1, and pkg-config witharch -x86_64 /usr/local/homebrew/bin/brew, and then adding the following values to~/.zshrc:After that, we ran
pip install -v --no-cache-dir xmlsecand we were able to use the package in pythonWe were actually having the opposite problem as https://github.com/mehcode/python-xmlsec/issues/163#issuecomment-1011940875 - we were trying to install xmlsec for x86_64 and it was looking for arm64 packages during the installation. If you’re trying to install it for arm64, find out where the arm64 version of
libxmlsec1is withbrew info libxmlsec1, and use that location for the LDFLAGS and CPPFLAGSAlso, we were still getting the ld warning for openssl after adding the LDFLAGS and CPPFLAGS to .zshrc - adding the relevant flags for libxmlsec1-openssl would probably fix that, but we stopped messing with things once it started working so I’m not sure
It installed on my M1 machine. You will need to build the wheel, thus, you will need to install
libxmlsec1andpkg-config. You might need tobrew updateand reinstall those packages. I have been able to builds the wheels for these versions: 1.3.10 to 1.3.12.Anyone trying this issue also make sure to only try with Python versions 3.8.10 and greater since that’s when official support was added.
Still having this issue on python 3.9 and M1. Any updates?
I get the same issue with
python 3.9on a M1 chip, any updates on this?@hitesh-raichandani I still can’t reproduce the issue due to missing hardware, but maybe you could attach the build log in the meantime? Simply
pip install xmlsec -vvv --force-reinstall --no-cache-dirand drop the full output in the comments.So what helped was installing --no-binary. Then I got another message: xmlsec.Error: (100, ‘lxml & xmlsec libxml2 library version mismatch’) Specified specif versions: pip install --no-binary=lxml lxml==5.3.0 pip install --no-binary=xmlsec xmlsec==1.3.14 now it works
@subavicky I’m working on a patch, but unfortunately can’t provide ETA
Same issue here. Tried all options you had suggested, nothing worked.
Howdy! Any updates on the progression for this issue? I understand the scenario and would like to hear back regarding workarounds.
Thanks
I’m running into the same issue except I am running python3.7 in the Rosetta2 compatibility mode
I do as well. symbol not found in flat namespace ‘_xmlSecOpenSSLTransformHmacRipemd160GetKlass’
Using xmlsec==1.3.12 with python 3.8.12 installed via rosetta-enabled homebrew (python@3.8) worked for me. Thanks @armenzg.