linux中安装python3
linux中安装python3
神奇海螺备份并替换阿里源
1 | tar -zcvf CentOS-bk.tar.gz /etc/yum.repos.d/CentOS-* |
1 | curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo |
1 | curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo |
安装依赖
1 | yum -y groupinstall "Development tools" |
1 | yum install -y ncurses-devel gdbm-devel xz-devel sqlite-devel tk-devel uuid-devel readline-devel bzip2-devel libffi-devel |
1 | yum install -y openssl-devel openssl11 openssl11-devel |
下载python 网地址:https://www.python.org/
1 | mkdir -p /doc/temp && cd /doc/temp |
1 | wget https://www.python.org/ftp/python/3.10.4/Python-3.10.4.tgz |
编译
1 | export CFLAGS=$(pkg-config --cflags openssl11) |
解压编译安装
1 | tar xvzf Python-3.10.4.tgz |
1 | cd Python-3.10.4 |
1 | ./configure --enable-optimizations && make altinstall |
验证
1 | /usr/local/bin/python3.10 --version |
1 | /usr/local/bin/pip3.10 --version |
配置
1 | ln -sf /usr/local/bin/python3.10 /usr/bin/python3 |
1 | ln -sf /usr/local/bin/pip3.10 /usr/bin/pip3 |
pip源
1 | mkdir -p ~/.pip |
1 | touch ~/.pip/pip.conf |
编辑配置文件
vim ~/.pip/pip.conf
1 | ```python |
上面配置了清华,豆瓣,阿里的源,并且关闭了ssl验证。当然如果有需要还可以设置代理,把注释掉的proxy那行放开即可。
再验证一下
1 | pip3 install --upgrade pip |
评论
匿名评论隐私政策
✅ 你无需删除空行,直接评论以获取最佳展示效果