![Ubuntu 16.04 Xenial 中‘lsb_release -a’出错](https://linux22.com/image/1142868/Ubuntu%2016.04%20Xenial%20%E4%B8%AD%E2%80%98lsb_release%20-a%E2%80%99%E5%87%BA%E9%94%99.png)
当我尝试 pip 安装 Django 或任何东西时出现错误,比如..
pip install Django
引发错误:
Traceback (most recent call last): File "/usr/local/bin/pip", line
11, in <module>
sys.exit(main()) File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 233, in
main
return command.main(cmd_args) File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 251,
in main
timeout=min(5, options.timeout)) as session: File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 72,
in _build_session
insecure_hosts=options.trusted_hosts, File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 329, in
__init__
self.headers["User-Agent"] = user_agent() File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 93, in
user_agent
from pip._vendor import distro File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line
1050, in <module>
_distro = LinuxDistribution() File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/distro.py", line
594, in __init__
if include_lsb else {} File "/usr/local/lib/python2.7/dist-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。它也已损坏,并抛出一个错误:
File "/usr/bin/lsb_release", line 64
print("No LSB modules are available.", file=sys.stderr)
^ SyntaxError: invalid syntax
问题可能出在哪里?我该如何解决?
答案1
我遇到了与您同样的问题,但查看文件后我能够解决问题/usr/bin/lsb_release
。
该文件的开头是#!/usr/bin/python3 -Es
,表示它使用 中的 Python 解释器/usr/bin/python3
。
在我的系统中,该文件是指向 python2.7 的符号链接。
我通过删除符号链接/usr/bin/python3
,然后将其替换为指向 python3.5 的正确符号链接来解决了该问题:
sudo ln -s /usr/bin/python3.5 /usr/bin/python3
答案2
抱歉回复这个“旧”帖子。
我最近也遇到了这个“lsb_release -a”错误Ubuntu 17.10。我终于解决了这个问题
sudo rm -rf /usr/bin/lsb_release
如果我将此文件保存在计算机中,即使我在其中指定了正确的 python 目录,它也会给出错误:subprocess.CalledProcessError:命令“lsb_release -a”返回非零退出状态 1。
因此,我从计算机中将其删除,然后它就可以正常工作了。