centos7.6安装python3

查看系统默认python

执行路径
[root@iZhp ~]# which python
/usr/bin/python
查看默认python配置和连接等

进入执行路径 cd /usr/bin/

[root@iZhp bin]# ll python*
lrwxrwxrwx 1 root root    7 Jul 11  2019 python -> python2
lrwxrwxrwx 1 root root    9 Jul 11  2019 python2 -> python2.7
-rwxr-xr-x 1 root root 7216 Jun 21  2019 python2.7
-rwxr-xr-x 1 root root 1835 Jun 21  2019 python2.7-config
lrwxrwxrwx 1 root root   16 Jul 11  2019 python2-config -> python2.7-config
lrwxrwxrwx 1 root root   14 Jul 11  2019 python-config -> python2-config
[root@iZ bin]# 

使用了多层软链接进行指向python2版本的执行路径

安装python3依赖包,源码安装使用

# 安装依赖库
yum -y install gcc* glien*
yum -y install zlib zlib-devel
yum -y install bzip2 bzip2-devel
yum -y install ncurses ncurses-devel
yum -y install readline readline-devel
yum -y install openssl openssl-devel
yum -y install openssl-static
yum -y install xz lzma xz-devel
yum -y install sqlite sqlite-devel
yum -y install gdbm gdbm-devel
yum -y install tk tk-devel
yum -y install libffi libffi-devel

python3 安装

  1. 下载文件 wget方式,源码安装
切换到、usr/local/目录下,将文件下载到该目录下
[root@iZh bin]# cd /usr/local/
[root@iZhp local]# ls
aegis  bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@iZhp local]# wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tar.xz
--2020-07-01 15:15:57--  https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tar.xz
Resolving www.python.org (www.python.org)... 151.101.228.223, 2a04:4e42:1a::223
Connecting to www.python.org (www.python.org)|151.101.228.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17828408 (17M) [application/octet-stream]
Saving to: ‘Python-3.8.1.tar.xz’

 1% [=>                                                                                                                              ] 298,631     10.5KB/s  eta 23m 52s

  1. 解压
tar -xvJf  Python-3.6.2.tar.xz
[root@iZ local]# ls
aegis  bin  etc  games  include  lib  lib64  libexec  Python-3.8.1  Python-3.8.1.tar.xz  sbin  share  src
  1. 配置: 指定安装路径
[root@iZhp local]# cd Python-3.8.1
[root@iZhp Python-3.8.1]# ./configure preifx=/usr/local/python3
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
  1. 编译安装

[root@iZhp Python-3.8.1]# 
[root@iZhp Python-3.8.1]# make && make install
gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration  -I./Include/internal  -I. -
........
Looking in links: /tmp/tmpp_opep1t
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.2.3 setuptools-41.2.0
  1. 创建链接: 同时创建python3 和pip3 的软连接
    pip3 安装路径在python3 安装路径下,3.8会按照在/usr/local/bin 中
ln -s /usr/local/python3/bin/python3 /usr/bin/python
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值