擅长:python、mysql、java
<p>Ubuntu 20.04存储库中不包括Python 2的Pip<br/>您需要使用get-pip.py脚本为Python 2安装pip。</strong></em></p>
<hr/>
<p><em>1。首先启用universe存储库:</em></p>
<pre><code>sudo add-apt-repository universe
</code></pre>
<p><em>2。更新包索引并安装Python 2:</em></p>
<pre><code>sudo apt update
sudo apt install python2
</code></pre>
<p><em>3。使用curl下载get-pip.py脚本:</em></p>
<pre><code>curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py
</code></pre>
<p><em>4。启用存储库后,使用python2以sudo用户身份运行脚本以安装pip:</em></p>
<pre><code>sudo python2 get-pip.py
</code></pre>
<p>如果出现错误,作为回退,可以使用特定的2.7版本的get-pip.py:</p>
<pre><code>curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
</code></pre>
<hr/>
<hr/>
<p>Pip将在全球范围内安装。如果只想为用户安装,请在不使用sudo的情况下运行该命令。该脚本还将安装setuptools和wheel,允许您安装源发行版</p>
<p><em>通过打印pip版本号来验证安装:</em></p>
<pre><code>pip2 --version
</code></pre>
<p>输出将如下所示:</p>
<pre><code> pip 20.0.2 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
</code></pre>