Linux 7下安装Python 3.6

在Linux 7版本中,系统默认自带python2.x的版本。随着python3.x的不断普及与广泛使用,越来越多的应用程序基于Python3开发。本文主要描述在Linux 7下使用编译方式安装Python 3。

一、当前环境

# more /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 

# python --version
Python 2.7.5

二、安装依赖包

# yum install gcc -y
# yum install zlib* -y

三、下载安装介质

# cd /usr/local/src
# wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz

四、安装配置Python

# tar -xf Python-3.6.4.tgz
# cd Python-3.6.4/
# ./configure
# make && make install

# ln -sv /usr/local/src/Python-3.6.4 /usr/local/python3
# /usr/local/python3/python --version
Python 3.6.4

### pip3也被一同安装
# pip3 -V
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

# ln -sv /usr/local/python3/python /usr/bin/python3

# python3
Python 3.6.4 (default, Sep 16 2018, 17:28:09) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello Python")
hello Python

# python
Python 2.7.5 (default, Nov 20 2015, 02:00:19) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

如上,两个版本同时并存

六、相关错误

错误1
configure: error: in `/usr/local/src/Python-3.6.4':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
# yum install gcc -y

错误2
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1
# yum install zlib* -y
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值