美文网首页pythonPythonLinux
linux环境如何安装Python3

linux环境如何安装Python3

作者: Joening | 来源:发表于2021-08-28 01:11 被阅读0次

安装依赖包

[root@pyhton ~]#  yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel gcc 

下载Python

下载地址: https://www.python.org/ftp/python

[root@pyhton ~]#  cd /opt/
[root@pyhton ~]#  wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
[root@pyhton ~]#  mkdir /usr/local/python3 
[root@pyhton ~]#  tar xf Python-3.7.9.tgz
[root@pyhton ~]#  cd Python-3.7.9
[root@pyhton ~]#  ./configure --prefix=/usr/local/pyhton3 
[root@pyhton ~]#  make 
[root@pyhton ~]#  make install 

设置环境变量

[root@pyhton ~]#  vim /etc/profile 
export PATH=/usr/local/python3/bin:$PATH
[root@pyhton ~]#  source /etc/profile 

验证

[root@pyhton ~]#  python3 -V 

备份就版本

[root@pyhton ~]# mv /usr/bin/python /usr/bin/python27
[root@pyhton ~]# ln -s /usr/local/python3/bin/python3 /usr/bin/python 
[root@pyhton ~]# python -V 
[root@pyhton ~]# Python 3.7.9

相关文章

网友评论

    本文标题:linux环境如何安装Python3

    本文链接:https://www.haomeiwen.com/subject/xphmiltx.html