安装python3一键脚本
适用系统 CentOS
Python3版本:3.11.0
安装编译Python3源文件所需的编译环境
1 2 3
| yum install -y gcc yum install -y zlib* 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 libffi-devel
|
下载并解压Python文件
1 2 3
| wget http://cdn.npm.taobao.org/dist/python/3.11.0/Python-3.11.0.tgz tar -zxvf Python-3.11.0.tgz cd Python-3.11.0/
|
指定安装目录
1
| ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
|
编译并安装
建立软链接
1 2
| ln -s /usr/local/python3/bin/python3 /usr/bin/python3 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
|
清理文件
1 2
| cd .. rm -rf Python-3.11.0/ Python-3.11.0.tgz
|
echo “安装完成.”
echo “安装目录:/user/local/pyhton3”
1 2
| python -m pip install --upgrade pip pip install --no-cache-dir --upgrade -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|
阿里云镜像
-i http://mirrors.aliyun.com/pypi/simple/ –trusted-host mirrors.aliyun.com
eg:
1
| pip install touch -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
|