CentOS 7.2 源码安装Python3.6

1.环境

安装CentOS 7.2最小系统(CentOS-7-x86_64-Minimal-1511.iso)

2.需求

Python-3.6.4.tar.xz(官网下载)

GCC(yum安装)

一堆开发库(yum安装)

3.编译

3.1安装编译器

yum -y install gcc

3.2安装依赖


yum -y install bzip2-devel sqlite-devel openssl-devel readline-devel xz-devel xz-devel tk-devel gdbm-devel

3.3编译源码

复制代码
tar Jxvf Python-3.6.4.tar.xz

cd Python-3.6.4

./configure

(如果需要发布版,则配置时要开优化,编译较慢./configure --enable-optimizations)
make -j4

make install
复制代码

默认安装到/usr/local

 

注意如果不安装3.2依赖开发库,则编译完成后会提示有些模块没有编译

复制代码
Python build finished successfully!
The necessary bits to build these optional modules were not found:
_bz2                  _curses               _curses_panel      
_dbm                  _gdbm                 _lzma              
_sqlite3              _ssl                  _tkinter           
readline              zlib                                     
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
atexit                pwd                   time               
running build_scripts
复制代码

4.运行

复制代码
[root@py3 Python-3.6.4]# python3
Python 3.6.4 (default, Jan 16 2018, 10:17:58) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值