2

CentOS7上Python-3.6的安装

 3 years ago
source link: http://www.eryajf.net/1491.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
本文预计阅读时间 3 分钟

1、先解决依赖

  1. 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 wget gcc gcc-c++

2,下载源码并安装。

  1. wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
  2. tar xf Python-3.6.3.tgz
  3. cd Python-3.6.3
  4. ./configure --prefix=/usr/local && make && make altinstall

3,更改/usr/bin/python链接

  1. cd /usr/bin && mv python python.backup && ln -s /usr/local/bin/python3.6 /usr/bin/python &&ln -s /usr/local/bin/python3.6 /usr/bin/python3 && ln -s /usr/local/bin/pip3.6 /usr/bin/pip

4,更改两个依赖。

  1. /usr/bin/yum
  2. /usr/libexec/urlgrabber-ext-down
分别把两个文件的第一行尾部加上2
  1. #!/usr/bin/python 改为 #!/usr/bin/python2
  2. sed -i '1s/python/python2/g' /usr/bin/yum
  3. sed -i '1s/python/python2/g' /usr/libexec/urlgrabber-ext-down

5,验证。

  1. [root@localhost bin]$python
  2. Python 3.6.3 (default, May 24 2018, 16:45:02)
  3. [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>>
  6. [root@localhost bin]$pip -V
  7. pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

weinxin

二丫讲梵 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明CentOS7上Python-3.6的安装

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK