如何使用 Python 3 安装 pip? [英] How to install pip with Python 3?

查看:36
本文介绍了如何使用 Python 3 安装 pip?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想安装 pip.它应该支持 Python 3,但它需要 setuptools,它仅适用于 Python 2.

如何使用 Python 3 安装 pip?

解决方案

edit:手动安装和使用 setuptools 不再是标准流程.

如果您运行的是 Python 2.7.9+ 或 Python 3.4+

恭喜,您应该已经安装了 pip.如果没有,请继续阅读.

如果您运行的是类 Unix 系统

如果您的 Python 版本早于 2.7.9 或 3.4,或者您的系统由于某种原因没有包含它,您通常可以通过您的包管理器安装 pip 的包.>

下面是一些更常见的发行版的说明.

在 Debian(Wheezy 和更新版本)和 Ubuntu(Trusty Tahr 和更新版本)上安装 Python 2.x

从终端运行以下命令:

sudo apt-get install python-pip

在 Debian(Wheezy 和更新版本)和 Ubuntu(Trusty Tahr 和更新版本)上安装 Python 3.x

从终端运行以下命令:

sudo apt-get install python3-pip

注意:

在全新的 Debian/Ubuntu 安装中,您可能无法找到该软件包:

sudo apt-get 更新

在 CentOS 7 for Python 2.x 上安装 pip

在 CentOS 7 上,你必须先安装安装工具,然后使用它来安装 pip,因为它没有直接的包.

sudo yum install python-setuptools须藤easy_install pip

在 CentOS 7 for Python 3.x 上安装 pip

假设您从 EPEL 安装了 Python 3.4 ,您可以安装 Python 3 的安装工具并使用它来安装pip.

# 第一个命令要求你为 CentOS7 启用 EPEL须藤 yum 安装 python34-setuptools须藤easy_install pip

如果你的 Unix/Linux 发行版没有它在包 repos 中

使用下面详述的手动方式安装.

手动方式

如果您想以手动方式进行安装,现在推荐的方法是使用 get-pip.py 脚本安装.io/en/stable/installing.html" rel="noreferrer">pip 的安装说明.

<块引用>

安装pip

要安装 pip,请安全下载 get-pip.py

然后运行以下命令(可能需要管理员权限):

python get-pip.py

如果 setuptools 尚未安装,get-pip.py 将为您安装 setuptools.

I want to install pip. It should support Python 3, but it requires setuptools, which is available only for Python 2.

How can I install pip with Python 3?

解决方案

edit: Manual installation and use of setuptools is not the standard process anymore.

If you're running Python 2.7.9+ or Python 3.4+

Congrats, you should already have pip installed. If you do not, read onward.

If you're running a Unix-like System

You can usually install the package for pip through your package manager if your version of Python is older than 2.7.9 or 3.4, or if your system did not include it for whatever reason.

Instructions for some of the more common distros follow.

Installing on Debian (Wheezy and newer) and Ubuntu (Trusty Tahr and newer) for Python 2.x

Run the following command from a terminal:

sudo apt-get install python-pip 

Installing on Debian (Wheezy and newer) and Ubuntu (Trusty Tahr and newer) for Python 3.x

Run the following command from a terminal:

sudo apt-get install python3-pip

Note:

On a fresh Debian/Ubuntu install, the package may not be found until you do:

sudo apt-get update

Installing pip on CentOS 7 for Python 2.x

On CentOS 7, you have to install setup tools first, and then use that to install pip, as there is no direct package for it.

sudo yum install python-setuptools
sudo easy_install pip

Installing pip on CentOS 7 for Python 3.x

Assuming you installed Python 3.4 from EPEL, you can install Python 3's setup tools and use it to install pip.

# First command requires you to have enabled EPEL for CentOS7
sudo yum install python34-setuptools
sudo easy_install pip

If your Unix/Linux distro doesn't have it in package repos

Install using the manual way detailed below.

The manual way

If you want to do it the manual way, the now-recommended method is to install using the get-pip.py script from pip's installation instructions.

Install pip

To install pip, securely download get-pip.py

Then run the following (which may require administrator access):

python get-pip.py 

If setuptools is not already installed, get-pip.py will install setuptools for you.

这篇关于如何使用 Python 3 安装 pip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆