centos7.4安装python3.7.4和pip3

1.去官网下载Python-3.7.4.tar.xz包,然后上传到服务器/usr/local/目录,或者使用wget去下载到/usr/local/
2.解压,没有xz就yum install xz

xz -d Python-3.7.4.tar.xz
tar zxvf Python-3.7.4.tar

3.安装依赖

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 gcc libffi-devel gcc make automake autoconf libtool libffi-devel

4.如果报错ModuleNotFoundError: No module named ‘_ctypes’

yum install libffi-devel -y

5.进入到解压目录

cd Python-3.7.4

6.创建安装目录

mkdir /usr/local/python3

7.安装

./configure --prefix=/usr/local/python3
make && make install

8.建立软连接,就是快捷方式

ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

9.如果安装完,使用pip3安装库报

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available

10.安装

yum install openssl-devel -y 

11.进入Python-3.7.4目录,执行

make clean
./configure --enable-optimizations --prefix=/usr/local/python3
make && make install

你可能感兴趣的:(python学习)