Error with 'lsb_release -a' in Ubuntu 16.04 Xenial

13,277

Solution 1

I am having the same issue as you, but I was able to solve the problem after looking at the file /usr/bin/lsb_release.

The beginning of the file is #!/usr/bin/python3 -Es, meaning that it is using the python interpreter in /usr/bin/python3.

In my system, that file was a symlink to python2.7.

I fixed the issue by removing the symlink /usr/bin/python3, and then replacing it with the correct symlink to python3.5:

sudo ln -s /usr/bin/python3.5 /usr/bin/python3

Solution 2

Sorry to reply this 'old' post.

I also encountered this 'lsb_release -a' error these days in Ubuntu 17.10. I finally solved this issue by

sudo rm -rf /usr/bin/lsb_release

If I keep this file in computer, even if I specify a correct python directory in it, it gives me the errors: subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1.

So, I deleted it in my computer and it works.

Share:
13,277
NINJA
Author by

NINJA

Updated on September 18, 2022

Comments

  • NINJA
    NINJA almost 2 years

    I am getting an error when i try to pip install Django or anything, say..

    pip install Django throws an error:

    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 
    

    Then I checked lsb_release -a in my system. it is also corrupted, throwwing an error:

      File "/usr/bin/lsb_release", line 64
        print("No LSB modules are available.", file=sys.stderr)
                                                   ^ SyntaxError: invalid syntax 
    

    Where could be the problem and how can I solve this?

    • NINJA
      NINJA over 7 years
      which python -> Python 2.7.12 | which pip -> pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
    • Rahul
      Rahul over 7 years
      Change line 64 as; print "No LSB modules are available.", file=sys.stderr
    • Chai T. Rex
      Chai T. Rex over 7 years
      Install debsums (sudo apt install debsums), then check the integrity of system files with sudo debsums -s. Are there any bad files?
    • NINJA
      NINJA over 7 years
      No sudo debsums -s not showing anything. Just empty.
    • NINJA
      NINJA over 7 years
      @Rahul python3 /usr/bin/lsb_release -a also throws the same error.
    • Rahul
      Rahul over 7 years
      python3 /usr/bin/lsb_release -a works for me but python2 /usr/bin/lsb_release -a gives error, are you sure you have installed python 3 not 2 beacause print can not be use like that in python 2.
    • NINJA
      NINJA over 7 years
      @Rahul Both versions are present. | which python3 /usr/bin/python3 || lrwxrwxrwx 1 root root 9 Aug 27 11:52 python3 -> python3.5
    • Rahul
      Rahul over 7 years
      post output of python3 -V and python -V.
    • NINJA
      NINJA over 7 years
      python -V >> Python 2.7.12 || python3 -V Python 3.5.1
  • Gabriel Fair
    Gabriel Fair about 6 years
    I'm not an expert but this seems dangerous to me. Isn't this a required file?
  • Fang
    Fang about 6 years
    No. lsb_release is part of a software package called the LSB core, which is not necessarily installed on your system by default. In case you need it again after removing it, just install it by 'sudo apt-get update && sudo apt-get install lsb-core' (for ubuntu).
  • Fang
    Fang about 6 years
    Not at all. I am happy with it.
  • cag51
    cag51 about 5 years
    The above answers didn't solve my problem on python3.7 and this one did. Thanks!
  • Fang
    Fang about 5 years
    You're so welcome!