python2.7升3.7_升级python2.7至python3.7
最近在centos7下執(zhí)行命令時(shí),出現(xiàn)以下提示:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
大概說的這個(gè)意思:
棄用:Python 2.7將在2020年1月1日結(jié)束它的生命。請升級你的Python,因?yàn)樵谀莻€(gè)日期之后Python 2.7將不會被維護(hù)。pip的未來版本將取消對Python 2.7的支持。關(guān)于pip中Python 2支持的更多細(xì)節(jié),可以在https://pip.pypa.io/en/latest/development/relee-process/ # python2 -support找到查看索引:http://mirrors.aliyun.com/pypi/simple/
centos7版本默認(rèn)安裝的是python2.7。于是,升級開始了。
注意下,應(yīng)為很多的依賴包基本命令什么的都是基于python2的,比如yum。所以舊版本不要刪了,新舊可以共存。
1.安裝編譯環(huán)境包(防止出現(xiàn)安裝錯(cuò)誤)
1 yum install gcc-c++ gcc make cmake zlib-devel bzip2-devel openssl-devel ncurse-devel libffi-devel -y
2.在線下載Python3.7源碼包
1 #進(jìn)入tmp目錄2 cd /tmp3 #下載python3.7.3
4 wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
3.解壓并配置
1 #解壓2 tar Jxvf Python-3.7.3.tar.xz3 #進(jìn)入python3.7.3目錄4 cd Python-3.7.3
5 #創(chuàng)建目錄6 mkdir -p /usr/local/python37 #配置(指定安裝目錄)8 ./configure --prefix=/usr/local/python3 --enable-optimizations
4.編譯及安裝
1 make && make install
5.更換系統(tǒng)默認(rèn)Python版本
1).備份原系統(tǒng)舊版本python
1 mv /usr/bin/python /usr/bin/python.bak2 mkdir /usr/bin/pip3 mv /usr/bin/pip /usr/bin/pip.bak
2).配置環(huán)境變量:創(chuàng)建新版本Python和pip的軟鏈接
1 ln -s /usr/local/python3/bin/python3.7 /usr/bin/python2 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
3).查看python版本
1 python -V
6.修改yum功能
因?yàn)閥um的功能依賴Pyhon2,現(xiàn)在更改默認(rèn)Python版本后會導(dǎo)致yum無法正常工作,所以進(jìn)行以下3處修復(fù)
第1處:
1 vim /usr/bin/yum
把最頂部的
改成:#!?/usr/bin/python2.7
第2處:
1 vim /usr/libexec/urlgrabber-ext-down
把最頂部的
改成:#!?/usr/bin/python2.7
/usr/sbin/firewalld/usr/bin/firewall-cmd
這兩個(gè)也改下
總結(jié)
以上是生活随笔為你收集整理的python2.7升3.7_升级python2.7至python3.7的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 上海欢乐谷儿童免费吗
- 下一篇: teamviewer设备数量上限_智能控