「Linux」centos7安装python
•安装python3.6可能使用的依赖
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc
•安装wget
yum -y install wget
•到python官网找到下载路径, 用wget下载
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
•解压tgz包
tar -zxvf Python-3.6.4.tgz
•把python移到/usr/local下面
mv Python-3.6.4 /usr/local
•进入python目录
cd /usr/local/Python-3.6.4/
•配置
./configure
configure: error: no acceptable C compiler found in $PATH可能会报这个错误,所以要安装最上面提到的gcc
•编译 make
make
•编译,安装
make install
•删除旧的软链接,创建新的软链接到最新的python
rm -rf /usr/bin/python
ln -s /usr/local/bin/python3.6 /usr/bin/python
python -V
•更新pip3
自带的pip3是9.0,更新命令:pip3 install --upgrade pip