编译Python动态库,出现error while loading shared libraries: libpython3.8.so.1.0: cannot open shared

前言

        在上一篇文字中【centos7 arm服务器编译安装python 3.8_python arm 安装-CSDN博客】中提到过,可以静态库编译,也可以动态库编译,如果编译是动态库的情况下,很容易出现以下的错误:

编译时报错:error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such fle or directory

解决办法:添加环境变量,vim ~/.bashrc,在末行添加以下几行代码:

export LD_LIBRARY_PATH=/usr/local/python3.8/lib:$LD_LIBRARY_PATH
source ~/.bashrc

再次运行python3命令就不会出现错误了。