当前位置:   article > 正文

pip、pip2、pip3

pip、pip2、pip3

os: centos 7.4

只安装 python2.x 的情况下,pip、pip2 均对应 python2.x,安装在 /usr/lib/pyhont2.x/dist-packages

只安装 python3.x 的情况下,pip、pip3 均对应 python3.x,安装在 /usr/lib/pyhont3.x/dist-packages

同时安装 python2.x、python3.x 的情况下,pip2 对应 python2.x,pip3 对应 python3.x.

pip 还需要通过源码来看对应 python2.x 还是 python3.x

当前 python2.x 已经不受支持。

版本

# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core) 

  • 1
  • 2
  • 3

pip2

# yum install python python-devel python-libs

  • 1
  • 2
# cd /root;
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py;
python get-pip.py;

# pip install setuptools;
pip install --upgrade setuptools;

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
# which pip
/usr/bin/pip

# which pip2
/usr/bin/pip2

# ls -l /usr/bin/pip*
-rwxr-xr-x 1 root root 220 May  5 00:00 /usr/bin/pip
-rwxr-xr-x 1 root root 220 May  5 00:00 /usr/bin/pip2
-rwxr-xr-x 1 root root 220 May  5 00:00 /usr/bin/pip2.7

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
# /usr/bin/pip -V
pip 20.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)

# /usr/bin/pip2 -V
pip 20.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

pip3

再安装 python3

# yum install python3 python3-devel python3-libs

  • 1
  • 2

会安装依赖包 python3-pip, 释放的可执行文件在 /usr/bin 目录下

# repoquery -ql python3-pip |more
/usr/bin/pip-3
/usr/bin/pip-3.6
/usr/bin/pip3
/usr/bin/pip3.6

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
# cd /tmp;
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py;
python3 get-pip.py;

# pip install setuptools;
pip install --upgrade setuptools;

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
# which pip
/usr/local/bin/pip

# which pip3
/usr/local/bin/pip3

# ls -l /usr/local/bin/pip*
-rwxr-xr-x 1 root root 221 May  4 23:51 /usr/local/bin/pip
-rwxr-xr-x 1 root root 221 May  4 23:51 /usr/local/bin/pip3
-rwxr-xr-x 1 root root 221 May  4 23:51 /usr/local/bin/pip3.6

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
# /usr/local/bin/pip -V
pip 20.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

# /usr/local/bin/pip3 -V
pip 20.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

卸载

# python -m pip uninstall pip

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Found existing installation: pip 20.1
Uninstalling pip-20.1:
  Would remove:
    /usr/bin/pip2
    /usr/bin/pip2.7
    /usr/lib/python2.7/site-packages/pip-20.1.dist-info/*
    /usr/lib/python2.7/site-packages/pip/*
Proceed (y/n)? y
  Successfully uninstalled pip-20.1
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
# python3 -m pip uninstall pip

Found existing installation: pip 20.1
Uninstalling pip-20.1:
  Would remove:
    /usr/local/bin/pip
    /usr/local/bin/pip3
    /usr/local/bin/pip3.6
    /usr/local/lib/python3.6/site-packages/pip-20.1.dist-info/*
    /usr/local/lib/python3.6/site-packages/pip/*
Proceed (y/n)?

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/563453
推荐阅读
相关标签
  

闽ICP备14008679号