Linux下编译安装Python-3.6.5

本文提供了详细的步骤来安装Python 3.6.5版本。从下载源码包开始,通过配置编译参数、解决编译过程中的错误到最终成功安装并验证安装结果。适合于希望手动编译安装Python的用户。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下载Python-3.6.5

[root@Master /]# cd /home
[root@Master home]# wget http://cdn.npm.taobao.org/dist/python/3.6.5/Python-3.6.5.tgz

解压Python-3.6.5.tgz

[root@Master home]# tar -zxvf Python-3.6.5.tgz

安装gcc和zlib等

[root@Master home]# yum install -y gcc
[root@Master home]# yum install -y zlib*
[root@Master Python-3.6.5]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel #确保pip的时候不会有出错

配置安装路径为/usr/local/python3

[root@Master home]# cd Python-3.6.5/
[root@Master Python-3.6.5]# ./configure --prefix=/usr/local/python3 --with-ssl

编译

[root@Master Python-3.6.5]# make

可能会遇到如下问题:

gcc: internal compiler error: Killed (program cc1)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
make: *** [Objects/unicodeobject.o] Error 4

修改Makefile文件,把‘-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes’中的‘O3’改为‘O2’

[root@Master Python-3.6.5]# vim Makefile

重新make后正常

安装

[root@Master Python-3.6.5]# make install

建立软链接

[root@Master Python-3.6.5]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@Master Python-3.6.5]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

测试

[root@Master Python-3.6.5]# python3
Python 3.6.5 (default, Apr 22 2018, 17:24:20)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello world')
hello world
>>>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值