本文介绍在CentOS 7/CentOS 8 Linux发行版上安装Python 3.8.1版本的方法,同时也安装了Pip,你可以根据本方法安装任何Python 3.8.X版本,当前Python的最新版本是Python 3.8.1,更新详情介绍可参考:Python 3.8.0发布,已提供Python-3.8.0.tgz下载,附更新功能。
一、安装Python依存关系 我们将从源代码安装Python,因此请安装Python安装所需的软件包: sudo yum -y groupinstall "Development Tools" sudo yum -y install openssl-devel bzip2-devel libffi-devel 确认gcc可用: $ gcc --version gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39) 参考:在RHEL 8/CentOS 8上安装GCC和Development Tools(开发工具)。
二、下载Python 3.8.1软件包 现在下载Python 3.8.1版本的软件包,在命令行中可运行以下命令: sudo yum -y install wget wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz 注:可到 https://www.python.org/downloads/ 下载任何一款Python 3.8版本。
解压缩包: tar xvf Python-3.8.1.tgz 更改创建的目录: cd Python-3.8*/
三、在CentOS 7/CentOS 8上安装Python 3.8.1 通过运行配置脚本来安装程序: ./configure --enable-optimizations 在CentOS 7/8上启动Python 3.8.1的编译: sudo make altinstall 如果成功,将收到以下消息: /tmp/tmp9ly9eo2d/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma? /tmp/tmp9ly9eo2d/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/ipaddress.py:1106: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma? Looking in links: /tmp/tmp9ly9eo2d Collecting setuptools Collecting pip Installing collected packages: setuptools, pip Successfully installed pip-19.2.3 setuptools-41.2.0 检查CentOS 8/CentOS 7上Python 3.8.1的安装: $ python3.8 --version; Python 3.8.1 Pip也已安装: $ pip3.8 --version pip 19.2.3 from /usr/local/lib/python3.8/site-packages/pip (python 3.8) 至此,在CentOS 7/CentOS 8发行版上安装Python 3.8.1完成了。
相关主题 |