ubuntu 下 安装pip3 的坑

如果在 ubuntu 下安装包,分在让能想到如下命令行操作:

zhangji16@zhangji16vm:~$ sudo apt-get install python3-pip
[sudo] zhangji16 的密码: 
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
python3-pip 已经是最新版 (8.1.1-2ubuntu0.4)。
下列软件包是自动安装的并且现在不需要了:
  libdbusmenu-gtk4 libllvm3.8 libmircommon5 libqmi-glib1 linux-headers-4.4.0-112 linux-headers-4.4.0-112-generic
  linux-headers-4.4.0-116 linux-headers-4.4.0-116-generic linux-headers-4.4.0-119 linux-headers-4.4.0-119-generic
  linux-headers-4.4.0-121 linux-headers-4.4.0-121-generic linux-headers-4.4.0-124 linux-headers-4.4.0-124-generic
  linux-headers-4.4.0-127 linux-headers-4.4.0-127-generic linux-headers-4.4.0-128 linux-headers-4.4.0-128-generic
  linux-headers-4.4.0-134 linux-headers-4.4.0-134-generic linux-headers-4.4.0-135 linux-headers-4.4.0-135-generic
  linux-headers-4.4.0-138 linux-headers-4.4.0-138-generic linux-headers-4.4.0-31 linux-headers-4.4.0-31-generic
  linux-image-4.4.0-112-generic linux-image-4.4.0-116-generic linux-image-4.4.0-119-generic linux-image-4.4.0-121-generic
  linux-image-4.4.0-124-generic linux-image-4.4.0-127-generic linux-image-4.4.0-128-generic linux-image-4.4.0-134-generic
  linux-image-4.4.0-135-generic linux-image-4.4.0-138-generic linux-image-4.4.0-31-generic linux-image-extra-4.4.0-112-generic
  linux-image-extra-4.4.0-116-generic linux-image-extra-4.4.0-119-generic linux-image-extra-4.4.0-121-generic
  linux-image-extra-4.4.0-124-generic linux-image-extra-4.4.0-127-generic linux-image-extra-4.4.0-128-generic
  linux-image-extra-4.4.0-134-generic linux-image-extra-4.4.0-135-generic linux-image-extra-4.4.0-138-generic
  linux-image-extra-4.4.0-31-generic ubuntu-core-launcher
使用'sudo apt autoremove'来卸载它(它们)。
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 65 个软件包未被升级。

似乎的我版本提醒我已经安装好了,那么我们 check 一下版本

zhangji16@zhangji16vm:~$ pip3 --version
程序“pip3”尚未安装。 您可以使用以下命令安装:
sudo apt install python3-pip

什么? 并没有安装成功 。这个也很奇怪,别人用这个命令

sudo apt-get install python3-pip

就能安装,我这里却不行 。所以我只能换一个方法 ,脚本安装 ,觉得很好用 , 具体如下操作:

zhangji16@zhangji16vm:~/c_study/test$ wget https://bootstrap.pypa.io/get-pip.py
--2019-01-21 08:49:18--  https://bootstrap.pypa.io/get-pip.py
正在解析主机 bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.76.175, 2a04:4e42:12::175
正在连接 bootstrap.pypa.io (bootstrap.pypa.io)|151.101.76.175|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 1661676 (1.6M) [text/x-python]
正在保存至: “get-pip.py”

get-pip.py                       100%[==========================================================>]   1.58M   337KB/s    in 5.1s    

2019-01-21 08:49:24 (316 KB/s) - 已保存 “get-pip.py” [1661676/1661676])

然后

zhangji16@zhangji16vm:~/c_study/test$ sudo python3 get-pip.py 
The directory '/home/zhangji16/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/zhangji16/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pip
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 13.8MB/s 
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-18.1
zhangji16@zhangji16vm:~/c_study/test$ pip3 -V
pip 18.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)

这下安装成功了。

猜你喜欢

转载自blog.csdn.net/m0_37329910/article/details/86568811