Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

解決一鍵安裝 LNMP 時 pycurl.so 缺少 CRYPTO_set_locking_callback 符號的報錯

問題現象

在執行 yum 相關操作時,系統突然拋出一段 Python 模組導入失敗的錯誤訊息:

There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
 /usr/lib64/python2.6/site-packages/pycurl.so: undefined symbol: CRYPTO_set_locking_callback
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.6.6 (r266:84292, Nov 22 2013, 12:16:22)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
If you cannot solve this problem yourself, please go to
the yum faq at:
 https://yum.baseurl.org/wiki/Faq

以上便是完整的報錯內容,下面直接進入排查與處理。

原因排查

這個問題多半是在安裝 LNMP 的過程中順帶編譯安裝了新的 libcurl,導致系統裡同時存在兩個版本的 libcurl,讓 yum 所依賴的 pycurl 連結到了不相容的函式庫。

先執行下面的指令看看系統辨識到幾個 libcurl:

ldconfig -v | grep libcurl

可能會看到類似以下的輸出:

ldconfig: 無法對 /usr/local/mysql/lib 進行 stat 操作: 沒有那個文件或目錄
ldconfig: 多次給出路徑"/usr/local/lib"
ldconfig: 多次給出路徑"/lib"
ldconfig: 多次給出路徑"/usr/lib"
ldconfig: 多次給出路徑"/usr/lib64"
ldconfig: 無法對 /usr/lib/libmcrypt.so 進行 stat 操作: 沒有那個文件或目錄
 libcurl.so.4 -> libcurl.so.4.4.0
 libcurl.so.4 -> libcurl.so.4.1.1

可以看到確實存在兩個 libcurl.so.4,這正是衝突的根源。

解決辦法

思路很簡單:讓 /usr/local/lib 下的新版本 soft link 指回系統原有的舊版本即可。先用 find 定位所有 libcurl.so.4:

find / -name libcurl.so.4

一般系統自帶的 libcurl 位於 /usr/lib64/libcurl.so.4 或 /usr/lib/libcurl.so.4。接著刪除多餘的那一份,再重建 soft link,最後刷新一次動態庫快取:

rm /usr/local/lib/libcurl.so.4
rm -rf /usr/local/lib/libcurl*
ln -s /usr/lib64/libcurl.so.4.1.1 /usr/local/lib/libcurl.so.4
ldconfig

完成後重新執行 yum,報錯即會消失。

Copyright © Linux教程網 All Rights Reserved