当前位置:   article > 正文

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

subprocess.calledprocesserror: command '('lsb_release', '-a')' returned non-

问题: 

使用pip的时候出现问题:

  1. ERROR: Exception:
  2. Traceback (most recent call last):
  3. File "/usr/local/python/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 188, in _main
  4. status = self.run(options, args)
  5. File "/usr/local/python/lib/python3.8/site-packages/pip/_internal/commands/uninstall.py", line 54, in run
  6. session = self.get_default_session(options)
  7. File "/usr/local/python/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 83, in get_default_session
  8. self._session = self.enter_context(self._build_session(options))
  9. File "/usr/local/python/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 93, in _build_session
  10. session = PipSession(
  11. File "/usr/local/python/lib/python3.8/site-packages/pip/_internal/network/session.py", line 249, in __init__
  12. self.headers["User-Agent"] = user_agent()
  13. File "/usr/local/python/lib/python3.8/site-packages/pip/_internal/network/session.py", line 132, in user_agent
  14. zip(["name", "version", "id"], distro.linux_distribution()),
  15. File "/usr/local/python/lib/python3.8/site-packages/pip/_vendor/distro.py", line 125, in linux_distribution
  16. return _distro.linux_distribution(full_distribution_name)
  17. File "/usr/local/python/lib/python3.8/site-packages/pip/_vendor/distro.py", line 681, in linux_distribution
  18. self.version(),
  19. File "/usr/local/python/lib/python3.8/site-packages/pip/_vendor/distro.py", line 741, in version
  20. self.lsb_release_attr('release'),
  21. File "/usr/local/python/lib/python3.8/site-packages/pip/_vendor/distro.py", line 903, in lsb_release_attr
  22. return self._lsb_release_info.get(attribute, '')
  23. File "/usr/local/python/lib/python3.8/site-packages/pip/_vendor/distro.py", line 556, in __get__
  24. ret = obj.__dict__[self._fname] = self._f(obj)
  25. File "/usr/local/python/lib/python3.8/site-packages/pip/_vendor/distro.py", line 1014, in _lsb_release_info
  26. stdout = subprocess.check_output(cmd, stderr=devnull)
  27. File "/usr/local/python/lib/python3.8/subprocess.py", line 411, in check_output
  28. return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  29. File "/usr/local/python/lib/python3.8/subprocess.py", line 512, in run
  30. raise CalledProcessError(retcode, process.args,
  31. subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.

注意上图的报错路径,在复制的时候要使用这个路径。

 

原因:

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

 

 

解决:

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

 

 

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

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号