简体   繁体   English

如何为 python 2.7 安装 pip?

[英]how to install pip for python 2.7?

I followed the link @ https://linuxize.com/post/how-to-install-pip-on-centos-7/#2-install-pip to install pip ,however its intalled for python 2.6 that comes with the system,how do I install it for python 2.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

Installing 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 version点子版本

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

Machine configuration:机器配置:

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 /usr/本地

在此处输入图像描述

Try installing manually:尝试手动安装:

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

pip has dropped a support to python 2.7. pip 已放弃对 python 2.7 的支持。 If you still want to use it for python 2.7, downgrading the pip will help you:如果您仍想将它用于 python 2.7,降级 pip 将帮助您:

sudo easy_install pip==20.3.4

In newer versions of Ubuntu such as 20.04, python-pip is no longer a package.在较新版本的 Ubuntu(例如 20.04)中,python-pip 不再是一个包。 Therefore, the old:因此,旧的:

sudo apt install python-pip

Will fail.将失败。

Here's how to work around this issue:以下是解决此问题的方法:

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
python get-pip.py

Link: https://www.how2shout.com/linux/how-to-install-python-2-7-on-ubuntu-20-04-lts-linux/链接: https ://www.how2shout.com/linux/how-to-install-python-2-7-on-ubuntu-20-04-lts-linux/

Just go into terminal and type in:只需进入终端并输入:

sudo apt-get install python-pip

I know that this at least works on a raspberry pi.我知道这至少适用于树莓派。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM