pip3 throws undefined symbol: XML_SetHashSalt

Viewed 7222

I am having python 3.6.8 on oracle Linux EL7 I installed pip3 using

yum install python36-pip

however, when ever I invoke pip3 it is having library error

pip3

Traceback (most recent call last):
  File "/bin/pip3", line 8, in <module>
    from pip import main
  File "/usr/lib/python3.6/site-packages/pip/__init__.py", line 42, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "/usr/lib/python3.6/site-packages/pip/utils/__init__.py", line 27, in <module>
    from pip._vendor import pkg_resources
  File "/usr/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 35, in <module>
    import plistlib
  File "/usr/lib64/python3.6/plistlib.py", line 65, in <module>
    from xml.parsers.expat import ParserCreate
  File "/usr/lib64/python3.6/xml/parsers/expat.py", line 4, in <module>
    from pyexpat import *
ImportError: /usr/lib64/python3.6/lib-dynload/pyexpat.cpython-36m-x86_64-linux-gnu.so: undefined symbol: XML_SetHashSalt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/bin/pip3", line 12, in <module>
    from pip._internal import main
  File "/usr/lib/python3.6/site-packages/pip/__init__.py", line 42, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "/usr/lib/python3.6/site-packages/pip/utils/__init__.py", line 27, in <module>
    from pip._vendor import pkg_resources
  File "/usr/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 35, in <module>
    import plistlib
  File "/usr/lib64/python3.6/plistlib.py", line 65, in <module>
    from xml.parsers.expat import ParserCreate
  File "/usr/lib64/python3.6/xml/parsers/expat.py", line 4, in <module>
    from pyexpat import *
ImportError: /usr/lib64/python3.6/lib-dynload/pyexpat.cpython-36m-x86_64-linux-gnu.so: undefined 
symbol: XML_SetHashSalt

I tried to see if there is any alternative to pyexpat.*.so but it seems there is none did ldd on the last line below is the out put

[root@whf00jkd python3.6]# ldd  /usr/lib64/python3.6/lib-dynload/pyexpat.cpython-36m-x86_64-linux-gnu.so
        linux-vdso.so.1 =>  (0x00007ffd76bf9000)
        libexpat.so.1 => /scratch/oraofss/app/oraofss/product/18.0.0/client_1/lib/libexpat.so.1 (0x00007fec3a94a000)
        libpython3.6m.so.1.0 => /lib64/libpython3.6m.so.1.0 (0x00007fec3a422000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fec3a206000)
        libc.so.6 => /lib64/libc.so.6 (0x00007fec39e38000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007fec39c34000)
        libutil.so.1 => /lib64/libutil.so.1 (0x00007fec39a31000)
        libm.so.6 => /lib64/libm.so.6 (0x00007fec3972f000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fec3ad81000)

I did a search for libexpat.so.1

[root@whf00jkd python3.6]# whereis libexpat.so.1
libexpat.so: /usr/lib/libexpat.so.1 /usr/lib/libexpat.so /usr/lib64/libexpat.so.1 /usr/lib64/libexpat.so
[root@whf00jkd python3.6]# ls -ltr /usr/lib/libexpat.so.1
lrwxrwxrwx. 1 root root 17 Apr  1  2019 /usr/lib/libexpat.so.1 -> libexpat.so.1.6.0
[root@whf00jkd python3.6]# ls -ltr /usr/lib64/libexpat.so.1
lrwxrwxrwx. 1 root root 17 Apr  1  2019 /usr/lib64/libexpat.so.1 -> libexpat.so.1.6.0

and added a link libexpat.so.1 -> /usr/lib/libexpat.so.1 in /usr/lib64/python3.6/lib-dynload/ but that is not removing the error

Please help

4 Answers

libexpat.so.1 pointing to wrong location. Fixed it with

export LD_LIBRARY_PATH=/lib64/:${LD_LIBRARY_PATH}
ldd /usr/lib64/python3.6/lib-dynload/pyexpat.cpython-36m-x86_64-linux-gnu.so
        linux-vdso.so.1 =>  (0x00007fff073f1000)
        libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f9ba53ce000)
        libpython3.6m.so.1.0 => /lib64/libpython3.6m.so.1.0 (0x00007f9ba4ea9000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f9ba4c8d000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f9ba48bf000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f9ba46bb000)
        libutil.so.1 => /lib64/libutil.so.1 (0x00007f9ba44b8000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f9ba41b6000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f9ba5807000)

I had the exact same error.

System Info

  • VM with CentOS 7.9
  • Python 3.6

Solution

We had another software installed that brought its own version of libexpat with it. We also modified the env variable LD_LIBRARY_PATH to include that software's lib directory. This caused pip to load the wrong library.

After unsetting LD_LIBRARY_PATH/removing the software from LD_LIBRARY_PATH, everthing was good.

This is what fixed the issue for me. I was using Python 3.6 and I tried installing a module using PIP. I was getting the below error.

ImportError: /opt/rh/rh-python36/root/usr/lib64/python3.6/lib-dynload/pyexpat.cpython-36m-x86_64-linux-gnu.so: undefined symbol: XML_SetHashSalt

Give ldd followed by the path to find the mapping.

ldd /opt/rh/rh-python36/root/usr/lib64/python3.6/lib-dynload/pyexpat.cpython-36m-x86_64-linux-gnu.so

Check the mapping for - libexpat.so.1. In my case it was referring to the oracle path which is incorrect -- /u01/oracle/product/12.1.0.2/lib/libexpat.so.1

So I renamed the libexpat.so.1 in the above directory.

After renaming, give ldd again and it should be pointing to /lib64/libexpat.so.1

Once the mapping is corrected, I was able to do pip install.

Thank you everyone for all your help.

Links which helped me:

https://ubuntuforums.org/showthread.php?t=2094005

https://askubuntu.com/questions/546654/python-error-when-opening-software-center

How did you install Python 3? On my Oracle Linux 7 installation, I installed python3 from ol7_latest on yum.oracle.com:

$ yum info python3
Installed Packages
Name        : python3
Arch        : x86_64
Version     : 3.6.8
Release     : 13.0.1.el7
Size        : 39 k
Repo        : installed
From repo   : ol7_latest

Without python36-pip installed, pip3 works as expected, for example:

$ pip3 install --user cx_Oracle
Collecting cx_Oracle
  Using cached https://files.pythonhosted.org/packages/16/1d/36ecde56e0522f1a1cea7b4d4333f88b1062e0c5287fc67f522ceacc053c/cx_Oracle-8.0.0-cp36-cp36m-manylinux1_x86_64.whl
Installing collected packages: cx-Oracle
Successfully installed cx-Oracle-8.0.0
Related