问题描述
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是否安装完成