error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory
在linux(centos)中编译安装python完成后,运行python3或python3 -V命令时,可能会报错
error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory
原因
centos系统默认加载/usr/lib,/lib下面库文件,python默认安装到非此类文件夹。(引自https://blog.csdn.net/learner198461/article/details/54598895)
解决办法
- 将python3安装目录的lib目录下的文件libpython3.6m.so.1.0复制到/usr/lib/目录下
# cp /usr/local/python3/lib/libpython3.6m.so.1.0 /usr/lib/
2. 将目录/usr/lib/添加到/etc/ld.so.conf.d/目录下的python3.6.conf文件中
# echo "/usr/lib" > /etc/ld.so.conf.d/python3.6.conf
3. 运行命令
# ldconfig
再运行 python3 或python3 -V,发现没有上述错误了