前言:
centos7自帶了python2,現(xiàn)在都使用python3了,但是python2不能刪除狸驳,要用到一些python2的命令,比如yum
正文:
1缩赛、輸入python查看版本
1.1 輸入which python查看位置
2耙箍、開(kāi)始安裝依賴(lài)包:
2.1? yum -y groupinstall "Development tools"
2.2? 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
3、根據(jù)自己的需求下載python3版本酥馍,我安裝的是3.9.9:
wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tar.xz
4辩昆、建立存放路徑:建立一個(gè)空文件夾,路徑隨意
mkdir /usr/local/python3
5旨袒、解壓安裝:
解壓:tar -xvJf? Python-3.9.9.tar.xz
切換目錄:cd Python-3.9.9
配置:./configure --prefix=/usr/local/python3
安裝:make && make install
6汁针、創(chuàng)建軟鏈接:
若不存在或覆蓋,ln?-sf 強(qiáng)制執(zhí)行
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
7砚尽、另外安裝uwsgi后也需要?jiǎng)?chuàng)建軟連接
ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi
ln -s /usr/local/python3/bin/scrapy /usr/bin/scrapy