下载python3安装包
https://www.python.org/ftp/python/3.8.10/Python-3.8.10.tgz
解压安装
代码语言:javascript复制tar xf Python-3.8.10.tgz
cd Python-3.8.10
./configure --prefix=/usr/local/python3 --enable-optimizations
make -j 4 && make install
添加环境变量
代码语言:javascript复制vim /etc/profile.d/python.sh
export PATH=$PATH:/usr/local/python3/bin
source /etc/profile.d/python.sh
- 或者设置软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
pip3 install --upgrade pip
验证python版本
安装tab补全解释器ipython
代码语言:javascript复制pip install ipython # python2安装ipython
pip3 install ipython # python3安装ipython
由于python2和python3安装的包名都叫ipython,当执行ipython命令的时候,默认使用的是python2的,如果要使用双版本的ipython,就要设置下软链接
代码语言:javascript复制ln -s /usr/local/python3/bin/ipython /usr/bin/ipython3