6

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?

muru
  • 207,228
NINJA
  • 61

2 Answers2

6

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
Zanna
  • 72,312
5

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.

Fang
  • 67