doupoa
一个不甘落后的热血青年!
Ping通途说

【问题解决】subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.

在进行pip任何操作时会展现以下错误:

ERROR: Exception:
Traceback (most recent call last):
  File "/usr/local/python3/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 173, in _main
    status = self.run(options, args)
  File "/usr/local/python3/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 203, in wrapper
    return func(self, options, args)
  File "/usr/local/python3/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 266, in run
    session = self.get_default_session(options)
  File "/usr/local/python3/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 74, in get_default_session
    self._session = self.enter_context(self._build_session(options))
  File "/usr/local/python3/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 88, in _build_session
    session = PipSession(
  File "/usr/local/python3/lib/python3.10/site-packages/pip/_internal/network/session.py", line 289, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/usr/local/python3/lib/python3.10/site-packages/pip/_internal/network/session.py", line 132, in user_agent
    linux_distribution = distro.linux_distribution()  # type: ignore
  File "/usr/local/python3/lib/python3.10/site-packages/pip/_vendor/distro.py", line 125, in linux_distribution
    return _distro.linux_distribution(full_distribution_name)
  File "/usr/local/python3/lib/python3.10/site-packages/pip/_vendor/distro.py", line 681, in linux_distribution
    self.version(),
  File "/usr/local/python3/lib/python3.10/site-packages/pip/_vendor/distro.py", line 741, in version
    self.lsb_release_attr('release'),
  File "/usr/local/python3/lib/python3.10/site-packages/pip/_vendor/distro.py", line 903, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')
  File "/usr/local/python3/lib/python3.10/site-packages/pip/_vendor/distro.py", line 556, in __get__
    ret = obj.__dict__[self._fname] = self._f(obj)
  File "/usr/local/python3/lib/python3.10/site-packages/pip/_vendor/distro.py", line 1014, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)
  File "/usr/local/python3/lib/python3.10/subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/local/python3/lib/python3.10/subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.

原因:

Python路径下缺少'lsb_release.py'模块

解决:

# 1.全盘查找lsb_release.py所在的目录

sudo find / -name 'lsb_release'

# 2.找到最新的结果,将其复制到Python的系统模块加载位置
cp /usr/lib/python3/dist-packages/lsb_release.py /usr/local/python3/lib/python3.10/
https://doupoa.site/wp-content/uploads/2022/02/1644733236-QQ截图20220213142007-1024x396.png

查看结果。可以看到pip已经可以正常使用了

https://doupoa.site/wp-content/uploads/2022/02/1644733259-image-1024x132.png

注意:不要使用 sudo rm /usr/bin/lsb_release 将文件删除,否则会有lsb_release相关问题出现

赞赏
# # # #
首页      Linux      【问题解决】subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.

doupoa

文章作者

诶嘿

发表回复

textsms
account_circle
email

Ping通途说

【问题解决】subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.
在进行pip任何操作时会展现以下错误: ERROR: Exception: Traceback (most recent call last): File "/usr/local/python3/lib/python3.10/site-packages/pip/_internal/cli/base_c…
扫描二维码继续阅读
2022-02-13

Optimized by WPJAM Basic