在centos7上安装pip(3)的推荐方式 [英] Recommended way to install pip(3) on centos7

查看:29
本文介绍了在centos7上安装pip(3)的推荐方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很想知道在当前版本的 centos7 (7.5.1804) 上为 python3.6(截至今天,2018 年 5 月)安装 pip3 的推荐方法以及 如何在 CentOS 7 中安装 pip? 似乎已经过时了,因为:

I am interrested in knowing the recommended way to install pip3 for python3.6 (as of today, may 2018) on current version of centos7 (7.5.1804) and the accepted answer of How to install pip in CentOS 7? seems to be outdated because:

yum search -v pip

输出(除其他外):

python2-pip.noarch : A tool for installing and managing Python 2 packages
Repo        : epel

python34-pip.noarch : A tool for installing and managing Python3 packages
Repo        : epel

python34-pip 似乎是一种(更新?)比 如何在 CentOS 7 中安装 pip? :

and python34-pip seems to be a (newer?) simpler way than the accepted answer of How to install pip in CentOS 7? :

sudo yum install python34-setuptools

sudo yum install python34-setuptools

sudo easy_install-3.4 pip

sudo easy_install-3.4 pip

但是由于我机器上安装的 python 版本是 2.7.5 和 3.6.3 为什么是 python34-pip 而不是 python36-pip ?3.4+(到当前的 3.6.3)的 pip 是否相同?

But since the versions of python installed on my machine are 2.7.5 and 3.6.3 why is it python34-pip and not python36-pip ? Is pip the same for 3.4+ (up to current 3.6.3) ?

推荐答案

3.4+ 的 pip 是否相同

Is pip the same for 3.4+

不,不是.单个 pip 安装服务于单个 Python 发行版(pip2.7/pip3.4/pip3.5 等).

No, it's not. A single pip installation serves a single Python distribution (pip2.7/pip3.4/pip3.5 etc).

从 Python 3.5 开始,pip 已经与 Python 发行版捆绑在一起,因此您可以运行 python3.6 -m pip 而不是 pip.

Since Python 3.5, pip is already bundled with the python distribution, so you can just run python3.6 -m pip instead of pip.

Python 3.6 在 CentOS 7 vanilla 存储库中不可用.当需要在 CentOS 上安装新的 Python 时,我通常求助于 IUS repo.它始终具有最新的 Python 版本,当前一个是 3.6.5.它还提供了一个通讯员 pip.

Python 3.6 is not available in CentOS 7 vanilla repo. I usually resort to IUS repo when needing to install a fresh Python on CentOS. It always has the most recent Python version, the current one being 3.6.5. It also offers a correspondent pip package.

$ yum install https://centos7.iuscommunity.org/ius-release.rpm
$ yum install python36u python36u-devel python36u-pip

不幸的是,IUS 尚未提供适用于 Python 3.7 的软件包,所以如果您正在 CentOS 7 上寻找 Python 3.7,从源代码构建是您唯一的选择.

Unfortunately, IUS doesn't offer a package for Python 3.7 yet so if you are looking for Python 3.7 on CentOS 7, building from source is your only option.

yum 不是一个选项时

您应该更喜欢这个答案中描述的引导解决方案,因为它是获得有效pip 已安装.

when yum is not an option

You should prefer the bootstrapping solution described in this answer as it is the most reliable way to get a working pip installed.

这篇关于在centos7上安装pip(3)的推荐方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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