centos7 安装 python3 pip3不能使用问题

本文提供了一份详细的CentOS7系统上安装Python3的步骤。从安装必要的依赖开始,到下载Python源码包、配置及编译安装,最后验证安装是否成功。附带了一个自动化安装脚本供读者使用。

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

终于可以输出一点经验了。。

总结了其他人的经验,经过自己尝试成功了

分享给大家做参考

os: centos 7

#安装gcc,否则在./configure时会error
yum install gcc

#安装openssl-devel,否则会忽略pip安装失败,但是没有error
yum install openssl-devel

#安装python3
wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tar.xz
xz -d Python-3.5.3.tar.xz
tar -xvf Python-3.5.3.tar
cd Python-3.5.3
./configure
make
make install

完成

 

最近这篇访问量大增,再发一个安装脚本吧。不是修复脚本!!!

适用于CentOS Linux release 7.7.1908 (Core),其他版本未测。

先下载Python-3.6.8.tar.xz 安装包,把脚本放到安装包相同路径,然后运行脚本。

#!/bin/bash
#author: unXeer
#date: 20200620 13:31:00
#description: wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz

set -e

if ! test -f `dirname $0`/Python-3.6.8.tar.xz && ! test -f `dirname $0`/Python-3.6.8.tar;then
    curl -o `dirname $0`/Python-3.6.8.tar.xz https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz
fi

yum install gcc -y
yum install openssl-devel -y
cd `dirname $0`

if test -f `dirname $0`/Python-3.6.8.tar.xz && ! test -f `dirname $0`/Python-3.6.8.tar; then
    xz -d Python-3.6.8.tar.xz
fi

tar -xvf Python-3.6.8.tar
cd Python-3.6.8
./configure
make && make install

cd - && rm -rf Python-3.6.8

python3 -V && pip3 --version

printf 'Use command `python3` or `pip3`\n'
printf '\t\t\tBy unXeer\n'

exit 0

 

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值