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)

这下安装成功了。

  • 7
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 20
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 20
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值