centos 7 安装Python 3.7

joyjoy0 2020-05-28

1.之前什么都没有做 直接下载Python3.7的包
tar -xzvf Python-3.7.2.tgz
cd Python-3.7.2
./configure --prefix=/usr/local/python3
make && make install
创建软连接
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
添加环境变量
vim /etc/profile

PATH="/usr/local/python3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"

source /etc/profile

安装上面一顿操作之后 各种问题

1.在普通用户下执行pytho3和pip3 没有问题但是在root用户下提示命令找不到
2.pip3 install 包的时候报错
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

解决:

1.切换到root用户下进行安装
2.openssl版本过低或者不存在 so
yum install openssl-devel -y 
3.cd Python-3.7.2
./configure --prefix=/usr/local/python3 --with-ssl
make && make install
创建软连接
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
添加环境变量
echo $PATH 如果存在 则不需执行以下命令
vim /etc/profile
在最后一行添加:
PATH="/usr/local/python3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"

source /etc/profile

通过以上测试在centos7 安装的python3.7 使用很舒服...

相关推荐