<p>我建议你不要碰默认的OS python安装。系统的其他部分可能依赖于它,没有办法知道升级是否会破坏某些东西,即使它不应该。在</p>
<p>我还建议您学习(如果您还没有,但我想您没有,因为这个问题)使用python虚拟环境,比如virtualenv。这允许您为您编写的每个项目设置特定的python环境。这意味着每个环境都可以有自己的python版本,除了该版本的标准python库之外,还可以为该项目使用pip安装任何其他第三方python库。这将项目彼此隔离。你不会因为另一个的升级而破坏一个。在</p>
<p>也就是说,如果您想保持Python版本的先进性,可以从源代码进行安装,然后使用altinstall参数将其安装到系统中(请参见自述文件.rstPython发行版的。这样,所有安装的版本都可以使用不同的名称(pip的名称相同),然后使用所需的版本创建每个虚拟环境。virtualenv有一个参数,可以根据需要应用特定(旧)版本。在</p>
<p>引用“安装多个版本”部分的自述:</p>
<blockquote>
<p>On Unix and Mac systems if you intend to install multiple versions of Python
using the same installation prefix (<code> prefix</code> argument to the configure
script) you must take care that your primary python executable is not
overwritten by the installation of a different version. All files and
directories installed using <code>make altinstall</code> contain the major and minor
version and can thus live side-by-side. <code>make install</code> also creates
<code>${prefix}/bin/python3</code> which refers to <code>${prefix}/bin/pythonX.Y</code>. If you
intend to install multiple versions using the same prefix you must decide which
version (if any) is your "primary" version. Install that version using <code>make
install</code>. Install all other versions using <code>make altinstall</code>.
For example, if you want to install Python 2.7, 3.6, and 3.8 with 3.8 being the
primary version, you would execute <code>make install</code> in your 3.8 build directory
and <code>make altinstall</code> in the others.</p>
</blockquote>
<p>最后,如果你还想做的话,其他答案也可以。在</p>