Fixing pycurl.so “undefined symbol: CRYPTO_num_locks” Breaking yum on RHEL/CentOS
This error typical indicates that pycurl is loading a libcurl linked against an incompatible OpenSSL version. The dynamic linker is likely picking up the wrong libcurl (often from a leftover custom install, such as a MySQL bundle), instead of the system one.
Symptom
Running yum (or any Python that imports pycurl) fails with:
/usr/lib64/python2.7/site-packages/pycurl.so: undefined symbol: CRYPTO_num_locks
Diagnose the mislinked library
- Inspect which shared libraries pycurl resolves at runtime:
ldd /usr/lib64/python2.7/site-packages/pycurl.so
- Look specifically at the path for libcurl.so. If it points to something under /usr/local, a vendor-specific directory, or a non-standard path, that’s a red flag.
- See what ldconfig knows about libcurl and where it prefers to load it from:
ldconfig -v | grep -E 'libcurl(\.so)?'
If multiple libcurl entries appear, note their directories. A non-system copy (for example, under /usr/local/lib or a MySQL-installed directory) may be shadowing the system libcurl.
- List the cached candidates and their origins:
ldconfig -p | grep -E 'libcurl(\.so)?'
This confirms which libcurl paths are registered in the dynamic linker cache.
Correct the linker search paths
- Review custom linker paths that might prioritize a non-system libcurl. Check the main config and drop-ins:
grep -H . /etc/ld.so.conf /etc/ld.so.conf.d/*.conf
If you see entries adding directories for a custom stack (e.g., a MySQL-provided lib directory), consider removing or commenting them out. For example:
vi /etc/ld.so.conf
- Remove or comment any line that injects a “local lib” ahead of system libs (such as /usr/local/lib or a vendor-specific lib directory) if it contains an incompatible libcurl.
- If a stray library directory was installed by a package you’ve already removed (e.g., a MySQL bundle that dropped its own libcurl), delete or rename that directory so it can’t be picked up:
# Example: adjust to the actual path you identified
mv /usr/local/mysql/lib /usr/local/mysql/lib.bak
- Rebuild the dynamic linker cache:
ldconfig
- Verify the cache and linkage again:
ldconfig -p | grep curl
ldd /usr/lib64/python2.7/site-packages/pycurl.so
- Ensure libcurl now resolves to the system path (typically under /usr/lib64 or /usr/lib on RHEL/CentOS).
Test yum
Once libcurl resolves to the correct system library, retry yum:
yum search pycurl
If the commmand runs without the CRYPTO_num_locks error, the mislinked libcurl has been removed from the search path and the issue is resolved.