(1)下载源码,我弄的3.78 https://www.python.org/downloads/release/python-378/ 找Gzipped source tarball
wget https://www.python.org/ftp/python/3.7.8/Python-3.7.8.tgz
(2)一堆包 yum install -y gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
(3)解压 tar -zxvf Python-3.7.8.tgz cd Python-3.7.8 ./configure && make && make install
(4)cd /usr/local/bin ll pytho* 可以看到安装的结果 -------------------- lrwxrwxrwx 1 root root 9 Aug 10 17:41 python3 -> python3.7 -rwxr-xr-x 2 root root 14001960 Aug 10 17:41 python3.7 lrwxrwxrwx 1 root root 17 Aug 10 17:41 python3.7-config -> python3.7m-config -rwxr-xr-x 2 root root 14001960 Aug 10 17:41 python3.7m -rwxr-xr-x 1 root root 2902 Aug 10 17:41 python3.7m-config lrwxrwxrwx 1 root root 16 Aug 10 17:41 python3-config -> python3.7-config --------------------------
(5)做软连接 rm -f /usr/bin/python rm -f /usr/bin/python-config ln -s /usr/local/bin/python3.7 /usr/bin/python ln -s /usr/local/bin/python3.7-config /usr/bin/python-config
(6)查看版本 python -V ----------------------------- pip自动安装了,用pip3即可 pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
-------------------------------------- 升级python后,yum会报错,因为它是用python2.x写的。
vim /usr/bin/yum vim /usr/libexec/urlgrabber-ext-down 第一行的 #!/usr/bin/python 都加个版本号,如替换成#!/usr/bin/python2.7
具体啥版本,到usr/bin下自己看看就好。
|