pip显示错误'lsb_release -a'返回非零退出状态1 [英] pip is showing error 'lsb_release -a' returned non-zero exit status 1
问题描述
我正在尝试使用pip安装软件包,并且抛出错误.
I am trying to install packages using pip and it is throwing error.
我使用的命令
sudo pip install selenium
显示的错误
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 272, in run
with self._build_session(options) 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)
CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1
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
我到处搜索过,但是没有解决此问题的方法.它最近开始表现得像这样.此外,软件更新程序也停止工作.不知道它是否与此有关.我正在使用Ubuntu 14.04 LTS和python 2.X
I have searched everywhere, but there is no solution for this problem. It started behaving like this recently. Also, Software Updater stopped working. Not sure if it is related to that. I am using Ubuntu 14.04 LTS and python 2.X
推荐答案
经典的lsb_release
问题.我已经多次与这个问题作斗争.问题是您的默认Python实现尝试使用Python 3,但lsb_release
需要Python2.要解决此问题,请执行以下操作:
Ahhh the classic lsb_release
issue. I have battled this problem many times. The issue is that your default Python implementation is trying to use Python 3 but lsb_release
requires Python 2. To fix this problem do the following:
- 打开
/usr/bin/lsb_release
(确保使用sudo或以root用户身份打开!) - 将第一行编辑为
#! /usr/bin/python2.7
- 保存文件
- Open
/usr/bin/lsb_release
(Make sure you use sudo or open as root!) - Edit the first line to be
#! /usr/bin/python2.7
- Save the file
现在您可以再次使用pip了,一切都会好起来的.
now you can use pip again and everything should be fine.
2019年5月更新:默认情况下,Python3附带较新版本的Linux.如此处评论所述,您可能只需要使用特定版本的Python 3.
UPDATE May 2019: Newer versions of Linux are shipping with Python3 by default. As noted in the comments here, you may just need to use a specific version of Python 3.
这篇关于pip显示错误'lsb_release -a'返回非零退出状态1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!