安装新包时调用lsb_release的pip错误

时间:2017-04-18 08:44:19

标签: python pip

我正在尝试配置2个Ubuntu服务器,以便为我的项目使用Python和Tensorflow。我完成了第一台服务器,然而,第二台服务器有一些非常不寻常和恼人的错误。这是我在第一台服务器上运行pip检查时的日志:

~$: pip check
No broken requirements found.

错误记录在第二个:

~$: pip check
No broken requirements found.

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

每次尝试使用pip安装新软件包时,此错误也会显示。有没有人遇到类似的pip问题或有办法诊断错误?

编辑1:

作为语言建议,我在两台机器上运行了lsb_release -a,这是第一个日志:

~$: lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:        16.04
Codename:       xenial

第二个:

~$: lsb_release -a
Traceback (most recent call last):
  File "/usr/bin/lsb_release", line 25, in <module>
    import lsb_release
ImportError: No module named 'lsb_release'

3 个答案:

答案 0 :(得分:2)

您可以使用default lsb_release或者稍微修改一下版本:

  1 #!/bin/bash

171     [ -z "$LSB_VERSION" ] && LSB_VERSION="1.4"

172 #$MSG_NA

答案 1 :(得分:0)

您的lsb_release二进制文件似乎已损坏。尝试重新安装lsb-release(ubuntu或debian包)。

答案 2 :(得分:0)

您没有提到系统上可用的Python版本。
不确定如何发生,但通常可以在Python v2和其他v3上运行“ lsb_version”。
您的主机上很可能有多个python版本。

subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero 
exit status 1

确实失败了,因为'/ usr / bin / lsb_release'调用的'lsb_release'库不适用于您的特定Python版本。 您首次尝试解决此问题的方法很简单:

sudo apt install lsb-release

注释是'-'而不是'_'

再试一次,如果仍然失败,请尝试以下操作:在/ usr / lib上查找您的Python版本库,并确认其中没有'lsb_release.py'。然后,将共享版本链接到您的媒体库:

ln -sfv /usr/share/pyshared/lsb_release.py /usr/lib/python3.7/site-packages/lsb_release.py

最后一个资源,在/usr中搜索任何lsb_release.py,并将其链接到您的Python库。

find /usr -name lsb_release.py