分类: Python
lsb_release.py报错解决

升级python版本后,安装pipenv报错如下:

env/vendor/pip9/download.py", line 329, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/usr/lib/python3/dist-packages/pipenv/vendor/pip9/download.py", line 93, in user_agent
    from pip9._vendor import distro
  File "/usr/lib/python3/dist-packages/pipenv/vendor/pip9/_vendor/distro.py", line 1050, in <module>
    _distro = LinuxDistribution()
  File "/usr/lib/python3/dist-packages/pipenv/vendor/pip9/_vendor/distro.py", line 594, in __init__
    if include_lsb else {}
  File "/usr/lib/python3/dist-packages/pipenv/vendor/pip9/_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

原因:

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

解决:

1、查找lsb_release.py文件位置:
sudo find / -name 'lsb_release.py'
/usr/share/pyshared/lsb_release.py
/usr/lib/python2.7/dist-packages/lsb_release.py
/usr/lib/python3/dist-packages/lsb_release.py

2、复制到升级后的python位置:
sudo cp /usr/lib/python3/dist-packages/lsb_release.py /usr/local/python39/lib/python3.9/

3、如果还是报错,尝试修改pipenv的python版本为之前稍低版本
sudo vim /usr/bin/pipenv
将#!/usr/bin/python3.7 换成之前的低版本即可。


相关博文:

发表新评论