文章目录
- 小结
- 问题
- 解决
- 参考
小结
在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]