1.下载安装包
[root@iZuf6a9cdcuwzty057~]# mkdir -p /opt/python3
[root@iZuf6a9cdcuwzty057~]# cd /opt/python3/
[root@iZuf6a9cdcuwzty057 python3]# wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
[root@iZuf6a9cdcuwzty057 python3]# tar -xvf Python-3.7.0.tar.xz
[root@iZuf6a9cdcuwzty057 python3]# cd Python-3.7.0/
2.编译安装
[root@iZuf6a9cdcuwzty057 Python-3.7.0]# ./configure --prefix=/usr/local/python3
[root@iZuf6a9cdcuwzty057 Python-3.7.0]# make && make install
--prefix
参数指定了软件的安装目录,该软件所有的安装文件都被复制到这个目录,其好处是方便我们卸载或移植软件,推荐使用。
3.新建软连接
[root@iZuf6a9cdcuwzty057 Python-3.7.0]# ln -sv /usr/local/python3/bin/python3.7.0 /usr/bin/python
输入python
[root@iZuf6a9cdcuwzty057 opt]# python
Python 3.7.0 (default, Dec 24 2021, 10:47:46)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
pip版本升级
python -m pip install --upgrade pip
官网https://pip.pypa.io/en/stable/installation/https://pip.pypa.io/en/stable/installation/