centos7.6下安装Python3.7.4

1.下载
wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
2.解压
tar -xzvf Python-3.7.4.tgz
3.配置
mkdir -p /usr/local/python3
进入解压后的Python-3.7.4
cd Python-3.7.4
./configure --prefix=/usr/local/python3/
4.编译
make
5.安装
make install
6.创建快捷方式
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
7.更新pip3
pip3 install --upgrade pip
8.环境变量中添加/usr/local/python3
vi .bash_profile
修改
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
退出编辑,激活配置:source .bash_profile

常见错误

错误:ModuleNotFoundError: No module named '_ctypes'
解决办法:yum install libffi-devel
错误:zipimport.ZipImportError: can‘t decompress data; zlib not availabl
解决办法:yum install zlib-devel
错误:No module named '_ssl'
解决办法:yum install openssl-devel,然后重新编译安装
错误:No module named '_sqlite3
解决办法:yum install sqlite-devel,然后重新编译安装
错误:ImportError: No module named Tkinter
解决办法:
yum install tkinter 
yum -y install tcl-devel tk-devel
重新编译安装

你可能感兴趣的:(centos7.6下安装Python3.7.4)