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

问题: 

使用pip的时候出现问题:

ERROR: Exception:
Traceback (most recent call last):
  File "/usr/local/python/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 188, in _main
    status = self.run(options, args)
  File "/usr/local/python/lib/python3.8/site-packages/pip/_internal/commands/uninstall.py", line 54, in run
    session = self.get_default_session(options)
  File "/usr/local/python/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 83, in get_default_session
    self._session = self.enter_context(self._build_session(options))
  File "/usr/local/python/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 93, in _build_session
    session = PipSession(
  File "/usr/local/python/lib/python3.8/site-packages/pip/_internal/network/session.py", line 249, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/usr/local/python/lib/python3.8/site-packages/pip/_internal/network/session.py", line 132, in user_agent
    zip(["name", "version", "id"], distro.linux_distribution()),
  File "/usr/local/python/lib/python3.8/site-packages/pip/_vendor/distro.py", line 125, in linux_distribution
    return _distro.linux_distribution(full_distribution_name)
  File "/usr/local/python/lib/python3.8/site-packages/pip/_vendor/distro.py", line 681, in linux_distribution
    self.version(),
  File "/usr/local/python/lib/python3.8/site-packages/pip/_vendor/distro.py", line 741, in version
    self.lsb_release_attr('release'),
  File "/usr/local/python/lib/python3.8/site-packages/pip/_vendor/distro.py", line 903, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')
  File "/usr/local/python/lib/python3.8/site-packages/pip/_vendor/distro.py", line 556, in __get__
    ret = obj.__dict__[self._fname] = self._f(obj)
  File "/usr/local/python/lib/python3.8/site-packages/pip/_vendor/distro.py", line 1014, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)
  File "/usr/local/python/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/local/python/lib/python3.8/subprocess.py", line 512, 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模块所在的目录
sudo find / -name 'lsb_release.py'

2、将其复制到设置python3.8的系统模块加载位置,也就是报错处subprocess.py所在的目录
sudo cp  /usr/lib/python3/dist-packages/lsb_release.py /usr/local/python/lib/python3.8/

 

 

注:不要使用 sudo rm /usr/bin/lsb_release 删除,会有lsb_release 相关操作问题报错。

  • 64
    点赞
  • 102
    收藏
    觉得还不错? 一键收藏
  • 14
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值