Python 在 Ubuntu 上安装 pip 的正确方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37954008/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Proper way to install pip on Ubuntu
提问by peflorencio
I'm trying to install the latest version of pip (currently 8.1.2) on the official ubuntu/trusty64 Vagrant box. The box comes with Python 2.7.6 and 3.4.3 pre-installed with apt-get.
我正在尝试在官方 ubuntu/trusty64 Vagrant box 上安装最新版本的 pip(当前为 8.1.2)。该盒子随附预装了 apt-get 的 Python 2.7.6 和 3.4.3。
I read the pip installation docand it contains the following warning:
我阅读了pip 安装文档,其中包含以下警告:
Be cautious if you're using a Python install that's managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state.
如果您使用的是由操作系统或其他包管理器管理的 Python 安装,请务必小心。get-pip.py 不与这些工具协调,并且可能会使您的系统处于不一致的状态。
Does that mean I cannot install pip using get-pip.py and I am limited to install an older version of it from apt-get?
这是否意味着我不能使用 get-pip.py 安装 pip 并且我只能从 apt-get 安装它的旧版本?
If there is a better way of installing it, what would it be?
如果有更好的安装方式,那会是什么?
Thanks
谢谢
回答by Michael Zhang
I believe that you can install it on Ubuntu with
我相信你可以在 Ubuntu 上安装它
sudo apt-get install python-pip
or
或者
sudo apt-get install python3-pip
for Python 3. Sure, it's an older version but its functionality is there.
适用于 Python 3。当然,它是一个较旧的版本,但它的功能在那里。
回答by MartinP
Try download install package from https://pypi.python.org/pypi/pip#downloadsand use python setup.py install
尝试从https://pypi.python.org/pypi/pip#downloads下载安装包并使用python setup.py install
回答by André Hulsman
if it is outdated you can use the following command:
sudo pip install --upgrade pip
如果它已过时,您可以使用以下命令:
sudo pip install --upgrade pip
回答by Santosh
If you are using Ubuntu OS with Python2.7 You can follow below steps
如果您使用带有 Python2.7 的 Ubuntu 操作系统,您可以按照以下步骤操作
apt-get update
apt-get upgrade
apt-get install python-pip
apt-get 更新
apt-get 升级
apt-get 安装 python-pip
To check install pip version
检查安装pip版本
pip --version
pip --version
OR
或者
If you are using Ubuntu OS with Python3 You can follow below steps
如果您使用带有 Python3 的 Ubuntu 操作系统,您可以按照以下步骤操作
apt-get update
apt-get upgrade
apt-get install python3-pip
apt-get 更新
apt-get 升级
apt-get 安装 python3-pip
To check install pip3 version
检查安装 pip3 版本
pip3 --version
pip3 --version
回答by Mike
The proper commands to install pip and pip3 should be the following:
安装 pip 和 pip3 的正确命令应如下所示:
sudo apt-get install python-pip python3-pip --yes
sudo python3 -m pip install pip --upgrade --force-reinstall
sudo python -m pip install pip --upgrade --force-reinstall # this must come after upgrading pip3
The last two lines get pip3and pipup-to-date. The last line is critical because it re-associates pipwith python 2.
最后两行获取pip3和pip最新信息。最后一行很关键,因为它将pip与 python 2重新关联。
回答by Hamed Jaliliani
This worked for me on ubuntu 18.0.4:
这在 ubuntu 18.0.4 上对我有用:
1- sudo apt-get update
2- sudo apt-get upgrade
3- sudo apt-get install python-pip
4- pip -V
回答by Roshan
sudo apt-get update;
sudo apt-get install python-pip;
sudo apt-get update;
sudo apt-get install python-pip;
Once the installation is complete, verify the installation by checking the pip version:
安装完成后,通过检查 pip 版本来验证安装:
pip --version;
pip --version;