前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Centos7下python2.x 和p

Centos7下python2.x 和p

作者头像
py3study
发布2020-01-03 11:14:38
4110
发布2020-01-03 11:14:38
举报
文章被收录于专栏:python3

摘要

目前centos7系统自带的Python版本是2.7.5,这个版本呗系统中的很多程序锁依赖,所有我们不可能去删除它。如果这个时候我们还想用python3.x 版本,其实这里有两个方式,一个是利用pyenv 创建一个纯净的python3.x 环境,可以参考Centos 下 python 纯净虚拟环境;另外一个就是这里介绍的。

下载

代码语言:javascript
复制
root@pts/0 $ wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
--2018-01-11 17:13:58--  https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
正在解析主机 www.python.org (www.python.org)... 151.101.228.223, 2a04:4e42:36::223
正在连接 www.python.org (www.python.org)|151.101.228.223|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:22540566 (21M) [application/octet-stream]
正在保存至: “Python-3.6.1.tgz”

100%[=========================================================================================>] 22,540,566  3.34MB/s 用时 7.8s

2018-01-11 17:14:06 (2.74 MB/s) - 已保存 “Python-3.6.1.tgz” [22540566/22540566])

依赖

正式安装之前,需要先安装一些依赖保证后续的安装正常进行

代码语言:javascript
复制
yum install -y gcc gcc-c++ autoconf automake zlib-devel

安装

代码语言:javascript
复制
# 解压
root@pts/0 $ tar -zxf Python-3.6.1.tgz
root@pts/0 $ ll
总用量 26112
drwxr-xr-x 17  501  501     4096 3月  21 2017 Python-3.6.1
-rw-r--r--  1 root root 22540566 3月  21 2017 Python-3.6.1.tgz

# 编译
默认会被安装到 /usr/local下面。这里我们通过configure  的--prefix参数自定义安装路径,方便以后的卸载

root@pts/0 $ cd Python-3.6.1
root@pts/0 $  ./configure --prefix=/usr/local/python3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for python3.6... no
checking for python3... no
checking for python... python
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no

# 安装
root@pts/1 $ make && make install

验证

代码语言:javascript
复制
root@pts/1 $ ls -l /usr/local/python3/
总用量 16
drwxr-xr-x 2 root root 4096 1月  11 17:09 bin
drwxr-xr-x 3 root root 4096 1月  11 17:09 include
drwxr-xr-x 4 root root 4096 1月  11 17:09 lib
drwxr-xr-x 3 root root 4096 1月  11 17:09 share

root@pts/1 $ /usr/local/python3/bin/python3 -V
Python 3.6.1

root@pts/1 $ /usr/local/python3/bin/python3
Python 3.6.1 (default, Jan 11 2018, 17:08:20)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/09/24 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 摘要
  • 下载
  • 依赖
  • 安装
  • 验证
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档