如何为python 2.7安装pip?

问题描述 投票:0回答:5

我按照链接@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

安装点子

 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 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

python pip centos
5个回答
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

2
投票

在较新版本的 Ubuntu(例如 20.04)中,python-pip 不再是一个包。因此,老:

sudo apt install python-pip

会失败。

以下是解决此问题的方法:

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

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


0
投票

pip 放弃了对 python 2.7 的支持。如果您仍然想在 python 2.7 中使用它,降级 pip 会对您有所帮助:

sudo easy_install pip==20.3.4

0
投票
  1. wget https://bootstrap.pypa.io/pip/2.7/get-pip.py

  2. python2 get-pip.py

  3. python2 -m Ensurepip --default-pip

  4. python2 -m pip install --升级 pip setuptools

  5. python2 -m pip install termcolor(termcolor是我要为python2安装的模块)

完成:)


-3
投票

只需进入终端并输入:

sudo apt-get install python-pip

我知道这至少适用于树莓派。

© www.soinside.com 2019 - 2024. All rights reserved.