centos6 x86 bbr 安装python3

1.  下载源码

wget  https://www.python.org/ftp/python/3.4.10/Python-3.4.10.tgz

2. 解压源码

tar zxvf Python-3.4.10.tgz

3.  编译和安装

./configure --with-ssl --prefix=/opt/python3   #会有大量日志

make #大量日志

sudo make install  # 会将可执行文件放到 /opt/python3目录下

4. 调整yum使用python

1. which python  # 查看系统默认python

    /usr/bin/python

2. cd /usr/bin     ll python* #两个命令

-rwxr-xr-x 2 root root 3592 Aug 18 2016 python

lrwxrwxrwx 1 root root 6 May 25 02:37 python2 -> python

-rwxr-xr-x 2 root root 3592 Aug 18 2016 python2.6

3. sudo cp /usr/bin/yum /usr/bin/yum.bak #备份

4. 将文件头部的#!/usr/bin/python改为#!/usr/bin/python2.6

sudo vim yum #进行修改

5. 将Python2 连接调整到 python2.6

sudo ln -snf python2.6 python2

6. 备份python

sudo mv python python.bak

7. 将python 连接到 /opt/python3/bin/python3

sudo ln -s /opt/python3/bin/python3 python


遇到的问题

1. [admin@74 Python-3.4.10]$ ./configure

checking build system type... i686-pc-linux-gnu 

checking host system type... i686-pc-linux-gnu 

checking for --enable-universalsdk... no 

checking for --with-universal-archs... no 

checking MACHDEP... linux 

checking for --without-gcc... no 

checking for gcc... no 

checking for cc... no 

checking for cl.exe... 

no configure: error: in `/home/admin/Python-3.4.10': 

configure: error: no acceptable C compiler found in $PATH 

See `config.log' for more details

没有安装gcc

sudo yum install gcc

2. ModuleNotFoundError: No module named '_ctypes'

sudo yum install libffi-devel

./configure --with-ssl --prefix=/opt/python3

make

sudo make install

4. 其他问题,openssl 版本太低时

sudo yum install openssl-devel

cd Python-3.4.10

./configure --with-ssl --prefix=/opt/python3

make

sudo make install

5.  关于ssl模块找不到的问题,详见

https://github.com/libressl-portable/portable/issues/381

libssl并没有完全实现openssl1.1版本的内容,这里安装了openssl1.1.1b版本

你可能感兴趣的:(centos6 x86 bbr 安装python3)