华为云:
https://mirrors.huaweicloud.com/python/
1、 下载 Python3代码包
https://www.python.org/downloads/release/python-365/
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
2、解压安装,指定安装路径
tar -zxvf Python-3.6.5.tgz \ && cd Python-3.6.5 \ && ./configure --prefix=/usr/local/python3 \ && make && make install
3、做软链
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3 ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
添加环境变量
$ vim ~/.bash_profile # python3 PYTHON_HOME=/usr/local/python3 export PATH=$PATH:$PYTHON_HOME/bin $ source ~/.bash_profile
4、测试
# python --version Python 2.7.5 # python3 --version Python 3.6.5
报错参考
1、centos 解决python3.7 安装时No module named _ssl
# 安装依赖 yum install -y zlib zlib-dev openssl-devel sqlite-devel \ bzip2-devel libffi libffi-devel gcc gcc-c++ zlib* # 安装最新版openssl wget http://www.openssl.org/source/openssl-1.1.1.tar.gz tar -zxvf openssl-1.1.1.tar.gz cd openssl-1.1.1 ./config --prefix=$HOME/openssl shared zlib make && make install # 设置环境变量 echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/openssl/lib" >> $HOME/.bash_profile source $HOME/.bash_profile # 解压安装 tar -zxvf Python-3.7.0.tgz ./configure --prefix=$HOME/Py37 --with-openssl=$HOME/openssl make && make install echo $HOME
2、解决问题:zipimport.ZipImportError: can’t decompress data; zlib not available
yum -y install zlib*
3、问题:
builtins.ModuleNotFoundError: No module named ‘_sqlite3’
yum install sqlite* 然后重新编译python或者重新安装python
参考: