版权声明:本文为博主原创文章,未经允许,严禁转载 https://blog.csdn.net/qq_26707177/article/details/89024361
[root@ansible-fcm /]# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make #安装python的
依赖包
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Complete!
[root@ansible-fcm Downloads]# wget http://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz #下载python安装包
--2019-04-04 03:31:16-- http://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
Resolving www.python.org (www.python.org)... 151.101.108.223, 2a04:4e42:36::223
Connecting to www.python.org (www.python.org)|151.101.108.223|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz [following]
--2019-04-04 03:31:17-- https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
Connecting to www.python.org (www.python.org)|151.101.108.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17049912 (16M) [application/octet-stream]
Saving to: ‘Python-3.6.5.tar.xz’
[root@ansible-fcm Downloads]# ll
total 16652
-rw-r--r--. 1 root root 17049912 Mar 28 2018 Python-3.6.5.tar.xz
[root@ansible-fcm Downloads]# xz -d Python-3.6.5.tar.xz #解压缩
[root@ansible-fcm Downloads]# ls
Python-3.6.5.tar
[root@ansible-fcm Downloads]# tar -xvf Python-3.6.5.tar #解压缩
[root@ansible-fcm Downloads]# ll
total 82176
drwxr-xr-x. 16 501 501 4096 Mar 28 2018 Python-3.6.5
-rw-r--r--. 1 root root 84142080 Mar 28 2018 Python-3.6.5.tar
[root@ansible-fcm Downloads]# cd Python-3.6.5/
[root@ansible-fcm Python-3.6.5]# ll
total 1040
-rw-r--r--. 1 501 501 13335 Mar 28 2018 aclocal.m4
-rwxr-xr-x. 1 501 501 44259 Mar 28 2018 config.guess
-rwxr-xr-x. 1 501 501 36515 Mar 28 2018 config.sub
-rwxr-xr-x. 1 501 501 490243 Mar 28 2018 configure
-rw-r--r--. 1 501 501 163178 Mar 28 2018 configure.ac
drwxr-xr-x. 18 501 501 4096 Mar 28 2018 Doc
drwxr-xr-x. 2 501 501 21 Mar 28 2018 Grammar
drwxr-xr-x. 2 501 501 4096 Mar 28 2018 Include
-rwxr-xr-x. 1 501 501 7122 Mar 28 2018 install-sh
drwxr-xr-x. 33 501 501 8192 Mar 28 2018 Lib
-rw-r--r--. 1 501 501 12763 Mar 28 2018 LICENSE
drwxr-xr-x. 8 501 501 160 Mar 28 2018 Mac
-rw-r--r--. 1 501 501 61032 Mar 28 2018 Makefile.pre.in
drwxr-xr-x. 2 501 501 4096 Mar 28 2018 Misc
drwxr-xr-x. 13 501 501 4096 Mar 28 2018 Modules
drwxr-xr-x. 4 501 501 4096 Mar 28 2018 Objects
drwxr-xr-x. 2 501 501 4096 Mar 28 2018 Parser
drwxr-xr-x. 6 501 501 4096 Mar 28 2018 PC
drwxr-xr-x. 2 501 501 4096 Mar 28 2018 PCbuild
drwxr-xr-x. 2 501 501 83 Mar 28 2018 Programs
-rw-r--r--. 1 501 501 42152 Mar 28 2018 pyconfig.h.in
drwxr-xr-x. 3 501 501 4096 Mar 28 2018 Python
-rw-r--r--. 1 501 501 9281 Mar 28 2018 README.rst
-rw-r--r--. 1 501 501 104570 Mar 28 2018 setup.py
drwxr-xr-x. 23 501 501 4096 Mar 28 2018 Tools
[root@ansible-fcm Python-3.6.5]# ./configure --prefix=/usr/Python-3.6.5 #编译配置
[root@ansible-fcm Python-3.6.5]# make #将源文件变成可执行文件
[root@ansible-fcm Python-3.6.5]# make install #安装python程序
[root@ansible-fcm bin]# ln -s /usr/Python-3.6.5/bin/python3 /usr/bin/python3 #添加软连接
[root@ansible-fcm bin]# python3 -V
Python 3.6.5
[root@ansible-fcm bin]# ln -s /usr/Python-3.6.5/bin/pip3 /usr/bin/pip3 #添加软连接
[root@ansible-fcm bin]# pip3 -V
pip 9.0.3 from /usr/Python-3.6.5/lib/python3.6/site-packages (python 3.6)
centos安装python3.6.5