很简单,但是每次安装都要现查,做个记录
cd /tmp wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz yum -y 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 mkdir /usr/local/python3 mv Python-3.6.7.tar.xz /usr/local/python3/ cd /usr/local/python3/ tar xf Python-3.6.7.tar.xz cd Python-3.6.7 ./configure --prefix=/usr/local/python3 make && make install ln -s /usr/local/python3/bin/python3 /usr/bin/python3 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
验证:
python3 Python 3.6.7 (default, Aug 12 2019, 00:26:52) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> >>> >>>
补充:
后续pip3安装时可能会报错,这里记录了两种报错的处理办法
#pip安装时报错ModuleNotFoundError: No module named '_ctypes'的解决办法 yum install libffi-devel #然后从config开始重新安装 #pip3 install时报错“pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.” 先安装openssl-dev,然后重新编译安装,只是在编译的过程中加入 --enable-optimizations