一、Python3.7.3源码下载
https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
二、解压
tar -xvf Python-3.7.3.tar.xz -C ./
三、开启SSL模块:
打开Python3.7.3/Modules/Setup.dist
_socket socketmodule.c #该行取消注释
# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl #该行取消注释
_ssl _ssl.c \ #该行取消注释
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ #该行取消注释
-L$(SSL)/lib -lssl -lcrypto #该行取消注释
四、编译安装Python
库:
CentOS:
yum install -y openssl-devel libffi-devel zlib zlib-devel gcc make
Ubuntu:
apt install libssl-dev libffi-dev zlib1g-dev gcc make
./configure --prefix=/usr/local/python3.7.3 --enable-optimizations #a release build with all stable optimizations active
#./configure --with-ssl-default-suites --prefix=/usr/local/python3
make
make install
五、链接
ln -s /usr/local/python3.7.3/bin/python3.7 /usr/bin/python373
#ln -s /usr/local/python3.7.3/bin/pip3.7 /usr/bin/pip373
检查版本
python373 --version
python373 -m pip -V
六、VSCode安装pylint
python373 -m pip install pylint --user
#python373 -m pip install pylint -i http://pypi.douban.com/simple --trusted-host pypi.douban.com --user
更新pip
python373 -m pip install --upgrade pip --user
#python373 -m pip install --upgrade pip -i http://pypi.douban.com/simple --trusted-host pypi.douban.com --user
加入/root/.local/bin到PATH
vim /etc/profile
PATH=$PATH:/root/.local/bin
export PATH
七、其他错误
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
cp /usr/lib/python3/dist-packages/lsb_release.py /usr/local/python373/lib/python3.7/
Fedora升级python3.7.4后dnf出错的问题
ln -s /usr/bin/python3.7 /usr/bin/python3
3.7.4没有python3-dnf包
Ubuntu升级Python3.7.4后apt出错的问题
ln -s /usr/bin/python3.7 /usr/bin/python3
不能ln 到新安装的/usr/local/python3/bin/python3.7
网友评论