问题描述:
使用conda安装了新版本的Python3.8,并且把对应的动态函数库加入了ld.so.cache
中(这是系统在软件运行时,用来搜索动态链接库的目录文件,具体见ldconfig的作用 & 编译时动态的链接问题 )。
但是系统自带的是python2.7,并且使用python2.7构建的yum。当调用yum的时候,yum希望搜索到python2.7的动态链接库,但是因为python3.8的函数库是后加进去的,所以先被yum搜索到,因此报出了如下动态链接库版本不兼容的问题。
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
/home/Js/ENTER/lib/liblzma.so.5: version `XZ_5.1.2alpha' not found (required by /lib64/librpmio.so.3)
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, Apr 2 2020, 13:16:51)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
解决办法
1.更新yum,使用conda的python3.8编译。(有点麻烦,现在时间不够,放弃)
2.删除现有的/etc/ld.so.cache
,删除/etc/ld.so.conf
文件内conda的函数库目录,运行ldconfig
命令重新生成/etc/ld.so.cache
(需要root权限,这些操作的解释可以参照ldconfig的作用 & 编译时动态的链接问题)。
sudo rm /etc/ld.so.cache
vim /etc/ld.so.conf #进去删除包含conda 函数库目录的那一行
sudo ldconfig
解决。
ps: 就是以后需要使用conda的动态链接库时候,需要使用如下命令指定。
export LD_LIBRARY_PATH=/conda/lib/directory/
意外收获
知道了centos的一个工具alternatives
,是用来管理多个版本的软件的工具。
- 使用参考 Centos使用alternatives切换Java版本
- 注意 使用install选项时,安装在
/usr/local/bin
目录下 How to update-alternatives to Python 3 without breaking apt?
参考
- 系统中更换默认的python 版本 How to change from default to alternative Python version on Debian Linux