centos安装python3

安装必要的包

yum groupinstall 'Development Tools'

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

下载源码

wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz

解压

tar -xvJf Python-3.6.6.tar.xz

配置安装

./configure    --prefix=/usr/local/python3    --enable-shared  --enable-optimizations

make && make install

 

软连接

ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

安装完成以后调用python3 报错
python3: 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默认安装到非此类文件夹。不过可以通过添加库配置信息

步骤如下:

  cd  /etc/ld.so.conf.d

  vim python3.conf   --新建配置文件

 编辑 添加库文件路径 /usr/local/python3/lib

 退出保存

 运行ldconfig

 

posted on 2018-08-02 18:56  awei1391  阅读(116)  评论(0编辑  收藏  举报

导航