在安装python3.9时遇到CentOS8默认安装了3.6版本,无法默认使用3.9版本的问题,特此记录
安装python3.9
参考文章
安装完成,查看linux系统上的python版本
>>>python3
Python 3.6.8 (default, Aug 24 2020, 17:57:11)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
>>>python3 --version
Python 3.6.8
>>>pip3 --version
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)
查看一下路径
>>> which python3
/usr/bin/python3
>>> which pip3
/usr/bin/pip3
>>> cd /usr/bin/
>>> ls -an python3
lrwxrwxrwx. 1 0 0 25 3月 31 12:20 python3 -> /etc/alternatives/python3
>>> ls -an pip3
lrwxrwxrwx. 1 0 0 22 3月 31 12:20 pip3 -> /etc/alternatives/pip3
查看一下所有python3相关的链接
>>>ls -an python3*
lrwxrwxrwx. 1 0 0 25 3月 31 12:20 python3 -> /etc/alternatives/python3
lrwxrwxrwx. 1 0 0 31 11月 4 12:04 python3.6 -> /usr/libexec/platform-python3.6
lrwxrwxrwx. 1 0 0 32 11月 4 12:04 python3.6m -> /usr/libexec/platform-python3.6m
找到python3.9的文件,非目录
-rwxr-xr-x. 1 root root 20436336 3月 31 20:50 python3.9
使用上面找到的目录进行链接修改
>>>ln -sb /usr/local/bin/python3.9 /usr/bin/python3
>>>python3 --version
Python 3.9.0a1
>>>ln -sb /usr/local/bin/pip3.9 /usr/bin/pip3
>>>pip3 --version
pip 19.2.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
验证一下python的版本现在是不是已经是3.9了
>>>python3
Python 3.9.0a1 (default, Mar 31 2021, 20:49:23)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
搞定!
PS:设定安装源
1.mkdir ~/.pip
2.vim ~/.pip/pip.conf
增加如下内容
[global]
timeout = 6000
index-url = https://pypi.douban.com/simple
trusted-host = pypi.douban.com
如果有用记得点个赞,留个言,让我知道这篇文章真的有用,谢谢