如何安装Python 2.7的pip?

7

我按照链接 @https://linuxize.com/post/how-to-install-pip-on-centos-7/#2-install-pip 安装了 pip,但它是安装在系统自带的 Python 2.6 上的,我该如何安装到 Python 2.7 上?

sudo yum install epel-release
Loaded plugins: security
Setting up Install Process
Package epel-release-6-8.noarch already installed and latest version
Nothing to do

安装pip
 sudo yum install python-pip
Loaded plugins: security
Setting up Install Process
Package python-pip-7.1.0-1.el6.noarch already installed and latest version
Nothing to do

pip版本

pip --version
pip 7.1.0 from /usr/lib/python2.6/site-packages (python 2.6)

机器配置:

LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: OracleServer
Description:    Oracle Linux Server release 6.6
Release:    6.6
Codename:   n/a

/usr/local

enter image description here


https://stackoverflow.com/search?q=%5Bpip%5D+install+pip+Python+2.7 - phd
@phd 这给我报错了 $ python get-pip.py pip被配置为需要 TLS/SSL 的位置,但是 Python 中的 ssl 模块不可用。 正在收集 pip .. 无法获取 URL https://pypi.org/simple/pip/ :存在确认 SSL 证书的问题:HTTPSConnectionPool(主机='pypi.org',端口=443):Max retries exceeded with url: /simple/pip/(由于 SSLError(“SSL模块不可用,因此无法连接到 HTTPS URL。”)而导致)-跳过 找不到与要求 pip(来自版本的版本)相匹配的发行版。 - user3508811
https://stackoverflow.com/search?q=%5Bpip%5D+is+configured+with+locations+that+require+TLS%2FSSL%2C+however+the+ssl+module+in+Python+is+not+available - phd
如果您在这里没有得到答案,您可能想尝试Unix&Linux Stack Exchange - wjandrea
显示剩余3条评论
4个回答

25
尝试手动安装:
wget -P ~/.local/lib https://bootstrap.pypa.io/pip/2.7/get-pip.py
python2.7 ~/.local/lib/get-pip.py --user 
#if using bash
printf "\nPATH=\$PATH:~/.local/bin/" >> ~/.bashrc
source ~/.bashrc

1
这个在第2步失败,错误信息是 Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping Could not find a version that satisfies the requirement pip (from versions: ) No matching distribution found for pip - user3508811
如何摆脱这个 SSL 错误?这一直是我遇到的障碍。 - user3508811
不,我没有自己编译Python...我似乎找不到/usr/local下的Python源代码,我该如何找到源代码? - user3508811
我添加了一个屏幕截图,展示了我的 /usr/local 目录的样子。 - user3508811
1
已更新为:https://bootstrap.pypa.io/pip/2.7/get-pip.py。您帖子中的URL现在只能与Python3一起使用。 - raw-bin hood
显示剩余7条评论

2

0

pip已经停止对Python 2.7的支持。如果您仍想在Python 2.7中使用它,降级pip将会有所帮助:

sudo easy_install pip==20.3.4

-3

只需进入终端并输入:

sudo apt-get install python-pip

我知道这至少在树莓派上可以工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接