编译安装curl后,使用yum报错 pycurl.so: undefined symbol: CRYPTO_num_locks

今天在CentOS7.6的系统上,自编译安装了OpenSSL 1.1.1和CURL 7.63并添到系统环境之后,发现使用yum安装出现报错,如下:

[root@Monitor ~]# yum install -y libffi-devel
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   /usr/lib64/python2.7/site-packages/pycurl.so: undefined symbol: CRYPTO_num_locks

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.5 (default, Oct 30 2018, 23:45:53) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

[root@Monitor ~]# ldd /usr/lib64/python2.7/site-packages/pycurl.so
        linux-vdso.so.1 =>  (0x00007ffc9b949000)
        libcurl.so.4 => /usr/local/curl/lib/libcurl.so.4 (0x00007f2e00937000)
        libpython2.7.so.1.0 => /lib64/libpython2.7.so.1.0 (0x00007f2e0056b000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f2e0034f000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f2dfff82000)
        libssl.so.1.1 => /usr/local/openssl/lib/libssl.so.1.1 (0x00007f2dffcf0000)
        libcrypto.so.1.1 => /usr/local/openssl/lib/libcrypto.so.1.1 (0x00007f2dff809000)
        libz.so.1 => /usr/local/lib/libz.so.1 (0x00007f2dff5ee000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f2dff3ea000)
        libutil.so.1 => /lib64/libutil.so.1 (0x00007f2dff1e7000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f2dfeee5000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f2e00dbb000)

情况很明显,是系统库动态链接调用到新装的CURL上,而导致部分定义未识别。就和之前的 let’s encrypt的错误一样,解决也和其一样,不过由于我自定义目录的关系,直接升级安装会报错,找不到ssl头:

[root@Monitor ~]# pip install --upgrade pycurl
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting pycurl
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/e8/e4/0dbb8735407189f00b33d84122b9be52c790c7c3b25286826f4e1bdb7bde/pycurl-7.43.0.2.tar.gz (214kB)
    100% |████████████████████████████████| 215kB 17.4MB/s 
Building wheels for collected packages: pycurl
  Running setup.py bdist_wheel for pycurl ... error
  Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-WJPkE9/pycurl/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-5kWHm3 --python-tag cp27:
  Using curl-config (libcurl 7.63.0)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  creating build/lib.linux-x86_64-2.7/curl
  copying python/curl/__init__.py -> build/lib.linux-x86_64-2.7/curl
  running build_ext
  building 'pycurl' extension
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/src
  gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/usr/local/curl/include -I/usr/include/python2.7 -c src/docstrings.c -o build/temp.linux-x86_64-2.7/src/docstrings.o
  In file included from src/docstrings.c:4:0:
  src/pycurl.h:164:28: fatal error: openssl/ssl.h: No such file or directory
   #   include <openssl/ssl.h>
                              ^
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for pycurl
  Running setup.py clean for pycurl
Failed to build pycurl
Installing collected packages: pycurl
  Found existing installation: pycurl 7.19.0
Cannot uninstall 'pycurl'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

添加参数即可解决:

[root@Monitor ~]# CPPFLAGS=-I/usr/local/openssl/include/ LDFLAGS=-L/usr/local/openssl/lib/ pip install --upgrade pycurl --ignore-installed pycurl
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting pycurl
Installing collected packages: pycurl
Successfully installed pycurl-7.43.0.2
[root@Monitor ~]# 

之后即可正常使用yum命令。

发表评论

error: Content is protected !!