操作系统
Ubuntu 16.04
默认python 3的版本是3.5
源码安装
下载python3.9
安装
(1)解压文件
tar -xvf Python-3.9.1.tar.xz
tar命令使用可以通过tar --help 来查看。
(2)进入解压后的文件夹
cd Python-3.9.1
(3)配置 配置文件
./configure --prefix=/usr/local/python3 --with-ssl
查看configure文件可以知道参数的作用:
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[$ac_default_prefix]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
. . .
--with-ssl-default-suites=[python|openssl|STRING]
override default cipher suites string, python: use
Python's preferred selection (default), openssl:
leave OpenSSL's defaults untouched, STRING: use a
custom string, PROTOCOL_SSLv2 ignores the setting,
see Doc/library/ssl.rst
(4)编译 make
(5)安装 sudo make install
(6)添加python3符号链结和pip3符号连接
sudo ln -s /usr/local/python3/bin/python3 /usr/bin/python3
sudo ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
(7)查看效果
pip3 -V
结果是:
pip 20.2.3 from /usr/local/python3/lib/python3.9/site-packages/pip (python 3.9)
公众号