很多粉丝来信说:安装新 python3 环境,要卸载操作系统原来自带的 python。。。
博主再次声明:不需用搞复杂了,相反可以同时具备多个环境,也不需用配置环境变量
无图无真相,且看此图:
详情操作,请参考此文!
1. PREPARE DEPENDENCIES
apt install -y vim wget gcc make zlib-devel zip zlib* libffi-dev
2. DOWNLOAD Python ( 3.7 - 3.12 ) tgz-ball
- 2.1 FROM HuaWeiCloud OpenMirror Site ( https://repo.huaweicloud.com/python/ )
wget https://repo.huaweicloud.com/python/3.7.3/Python-3.7.3.tgz
wget https://repo.huaweicloud.com/python/3.8.5/Python-3.8.5.tgz
wget https://repo.huaweicloud.com/python/3.9.5/Python-3.9.5.tgz
wget https://repo.huaweicloud.com/python/3.10.5/Python-3.10.5.tgz
wget https://repo.huaweicloud.com/python/3.11.5/Python-3.11.5.tgz
wget https://repo.huaweicloud.com/python/3.12.4/Python-3.12.4.tgz
- 2.2 You can also from Python.org ( https://www.python.org/ftp/python/ )
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz
wget https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz
wget https://www.python.org/ftp/python/3.10.5/Python-3.10.5.tgz
wget https://www.python.org/ftp/python/3.11.5/Python-3.11.5.tgz
wget https://www.python.org/ftp/python/3.12.4/Python-3.12.4.tgz
3. CREATE INSTALL Python3 Package Directory
mkdir /usr/local/python{37,38,39,310,311,312}
4. INSTALL Python 3.x
4.1 INSTALL Python 3.7
tar -zxf Python-3.7.3.tgz
cd Python-3.7.3
./configure prefix=/usr/local/python37
make -j 8;make install -j 8
ln -s /usr/local/python37/bin/python3.7 /usr/bin/python37
ln -s /usr/local/python37/bin/pip3.7 /usr/bin/pip37
python37 -m pip install --upgrade pip
python37 -V
pip37 -V
4.2 INSTALL Python 3.8
tar -zxf Python-3.8.5.tgz
cd Python-3.8.5
./configure --prefix=/usr/local/python38/
make -j 8;make install -j 8
ln -s /usr/local/python38/bin/python3.8 /usr/bin/python38
ln -s /usr/local/python38/bin/pip3.8 /usr/bin/pip38
python38 -m pip install --upgrade pip
python38 -V
pip38 -V
4.3 INSTALL Python 3.9
tar -zxf Python-3.9.5.tgz
cd Python-3.9.5
./configure --prefix=/usr/local/python39
make -j 8;make install -j 8
ln -s /usr/local/python39/bin/python3.9 /usr/bin/python39
ln -s /usr/local/python39/bin/pip3.9 /usr/bin/pip39
python39 -m pip install --upgrade pip
python39 -V
pip39 -V
4.4 INSTALL Python 3.10
tar -zxf Python-3.10.5.tgz
cd Python-3.10.5
./configure --prefix=/usr/local/python310
make -j 8;make install -j 8
ln -s /usr/local/python310/bin/python3.10 /usr/bin/python310
ln -s /usr/local/python310/bin/pip3.10 /usr/bin/pip310
python310 -m pip install --upgrade pip
python310 -V
pip310 -V
4.5 INSTALL Python 3.11
tar -zxf Python-3.11.5.tgz
cd Python-3.11.5
./configure --prefix=/usr/local/python311/
make -j8;make install -j 8
ln -s /usr/local/python311/bin/python3.11 /usr/bin/python311
ln -s /usr/local/python311/bin/pip3.11 /usr/bin/pip311
python311 -m pip install --upgrade pip
python311 -V
pip311 -V
4.6 INSTALL Python 3.12
tar -zxf Python-3.12.4.tgz
cd Python-3.12.4
./configure --prefix=/usr/local/python312/
make -j 8; make install -j 8
ln -s /usr/local/python312/bin/python3.12 /usr/bin/python312
ln -s /usr/local/python312/bin/pip3.12 /usr/bin/pip312
python312 -m pip install --upgrade pip
python312 -V
pip312 -V
我们下期见,拜拜!