Installieren Sie Python3 auf Centos

1. Überprüfen Sie die Python-Version

   [root@bogon ~]# python -V
   Python 2.7.5
   [root@bogon ~]#

2. Installieren Sie die erforderlichen Bibliotheksdateien

yum -y install zlib zlib-devel gcc
很重要,要不装不了包
yum install openssl-devel -y

3. Laden Sie python3.6.1 in das Verzeichnis /usr/local herunter

wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz

4. Entpacken und installieren

  # xz -d Python-3.6.1.tar.xz
  # tar -xvf Python-3.6.1.tar
  # cd Python-3.6.1/
  # ./configure prefix=/usr/local/python3
  # make && make install

5. Fügen Sie Umgebungsvariablen dauerhaft hinzu

  #vim/etc/profile
 添加export PATH="\$PATH:/usr/local/python3/bin"
添加完成后 source /etc/profile
**临时添加环境变量为 # export         PATH="$PATH:/usr/local/python3/bin" 终端结束后环境变量生效

6. Öffnen Sie Python3.6

[root@bogon ~]# python3
Python 3.6.1 (default, May 19 2017, 04:11:00)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.

7. Ändern Sie den Link /usr/bin/python

  # cd/usr/bin
  # mv python python.bak
  # ln -s /usr/local/python3/bin/python3.6 /usr/bin/python
  # ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
  修改后可直接用 # python打开python3

おすすめ

転載: blog.csdn.net/qq_38072531/article/details/78836464