pip命令不能使用,报错 from pip._internal import cmdoptions ImportError: cannot import name cmdoptions

问题描述

win10安装xgboost 的时候发现pip命令不能使用,报错内容如下:
      from pip._internal import cmdoptions  
ImportError: cannot import name cmdoptions  

此问题为pip损坏所致
执行pip --version 命令仍然报出此错误

解决方法:
参照官网 https://packaging.python.org/tutorials/installing-packages/  中的一段文字:

If pip isn’t already installed, then first try to bootstrap it from the standard library:

 python -m ensurepip --default-pip
If that still doesn’t allow you to run pip:

Securely Download get-pip.py [1]

Run python get-pip.py. [2] This will install or upgrade pip. Additionally, it will install setuptools and wheel if they’re not installed already.

Warning Be cautious if you’re using a Python install that’s managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state. You can use python get-pip.py --prefix=/usr/local/ to install in /usr/local which is designed for locally-installed software.

通过如上内容做如下操作:
1、 首先执行命令:   python -m ensurepip --default-pip
2、 下载  get-pip.py 文件  地址为   https://bootstrap.pypa.io/get-pip.py
3、 最后从命令行进入到  get-pip.py  所在的目录,执行命令 :  python get-pip.py  
       注意 此步骤执行的时候可能会报出权限错误, 此时应执行   python get-pip.py  --user

执行 pip --version 查看pip是否安装完成
    

  • 6
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值