Red Hat 8中安装Python3.8.8和pip3

小结

在Red Hat 8.3中成功安装Python3.8.8和pip3。

问题

运行Python返回错误SyntaxError: future feature annotations is not defined,发现的问题是程序要求Python3.8解释器,然而现有安装版本是Python3.6。

解决

分别安装Python3.8.8和pip3,步骤如下:

删除Python3.6

[root@Master ~]]# yum remove python36

安装Python3.8和pip3

[root@Master ~]]# yum install python38
[root@Master ~]]# yum install python38-pip

设置默认Python和Pip版本

[root@Master ~]# cat ~/.bash_aliases 
alias python=/usr/bin/python3.8
alias python3=/usr/bin/python3.8
alias pip=/usr/bin/pip3
[root@Master ~]# source ~/.bash_aliases

检查成功设置:

[root@Master ~]# python
Python 3.8.8 (default, Aug 11 2021, 06:52:42) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
[root@Master ~]# python -V
Python 3.8.8
[root@Master ~]# python3 -V
Python 3.8.8
[root@Master ~]# pip -V
pip 19.3.1 from /usr/lib/python3.8/site-packages/pip (python 3.8)
[root@Master ~]# pip3 -V
pip 19.3.1 from /usr/lib/python3.8/site-packages/pip (python 3.8)

参考

How to make python3.7 default
Red Hat: Chapter 38. Configuring the unversioned Python
How to change python default version from 2.7 to 3.7 on RHEL 7
Setting the Default python to python3
How to install pip in RHEL 8 / CentOS 8
Stackoverflow: SyntaxError: future feature annotations is not defined [duplicate]

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值