pip 更新至版本 9.0.1 后出现的问题(在 Ubuntu 10.04 上)

pip 更新至版本 9.0.1 后出现的问题(在 Ubuntu 10.04 上)

我在 ubuntu 10.04 上安装了 python 2.7.12。我已更新点子从 8.1.2 到最新版本(9.0.1)但是现在当我运行 pip(例如pip freeze或任何其他命令)时出现此错误:

 Traceback (most recent call last):

 File "/usr/local/bin/pip", line 11, in <module>
    sys.exit(main())
 File "/usr/local/lib/python2.7/site-packages/pip/__init__.py", line 233, in main
    return command.main(cmd_args)
 File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 251, in main
    timeout=min(5, options.timeout)) as session:
 File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 72, in _build_session
    insecure_hosts=options.trusted_hosts,
 File "/usr/local/lib/python2.7/site-packages/pip/download.py", line 329, in __init__
    self.headers["User-Agent"] = user_agent()
 File "/usr/local/lib/python2.7/site-packages/pip/download.py", line 93, in user_agent
    from pip._vendor import distro
 File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distro.py", line 1050, in <module>
    _distro = LinuxDistribution()
 File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distro.py", line 594, in __init__
    if include_lsb else {}
 File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distro.py", line 933, in _get_lsb_release_info
    raise subprocess.CalledProcessError(code, cmd, stdout)
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1

读取回溯后,我尝试执行该命令lsb_release -a并返回:ImportError: no module named lsb_release

有什么想法可以解决这个问题吗?

答案1

该问题存在于多个 Ubuntu 版本(16.04、某些 16.10)以及您的版本中。

甚至基本pip list -o失败(这将证实情况)。

值得注意的是,OS python 和自安装模块可能会出现问题,因此请自行承担“风险”。

移除当前点子

sudo su - 
pip uninstall pip

得到点子安装程序:

wget https://bootstrap.pypa.io/get-pip.py

(重新)安装点子

python get-pip.py

更新所有鸡蛋:

for i in `pip list -o --format legacy|awk '{print $1}'` ; do pip install --upgrade $i; done

相关内容