一、下载
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1rc2.tgz
二、解压
tar zxvf Python-3.7.1rc2.tgz cd Python-3.7.1rc2
相关推荐:《Python平台》
三、编译
./configure make make install
先找的python3.7解释器位置,一般是:
/usr/local/bin/python3.7
四、删除原来的软连接
rm -rf /usr/bin/python3 rm -rf /usr/bin/pip3
五、添加python3的软连接
ln -s /usr/local/bin/python3.7 /usr/bin/python3 #添加 pip3 的软链接 ln -s /usr/local/bin/pip3.7 /usr/bin/pip3
六、问题备忘
问题一: 报错ModuleNotFoundError: No module named '_ctypes'
解决方法:
sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade sudo apt-get install build-essential python-dev python-setuptools python-pip python-smbus sudo apt-get install build-essential libncursesw5-dev libgdbm-dev libc6-dev sudo apt-get install zlib1g-dev libsqlite3-dev tk-dev sudo apt-get install libssl-dev openssl sudo apt-get install libffi-dev
问题二: zipimport.ZipImportError: can’t decompress data; zlib not available
解决方法:
sudo apt-get install zlib*
问题三: 出现locations that require TLS/SSL异常处理方法
sudo apt-get install gcc libffi-devel zlib* openssl-devel
然后重新编辑和安装python3.7即可。