2

So I was having some trouble with python package incompatibilities. I was tired of troubleshooting and decided that I would remove all of the packages that I had installed using pip3. In an attempt to do this, I stupidly removed all files under the /usr/lib/python3/dist-packages directory using this command:

sudo rm -R /usr/lib/python3/dist-packages/*

After doing this, I tried to use pip3 to reinstall the packages that I needed, but all of a sudden, the pip3 command would not work and instead display a lengthy error message. I tried uninstalling and reinstalling python3-pip and python-pip, but the error would not go away. At this point, I don't know what to do to fix pip3, so I would really appreciate any help with helping to understand the error message, and to fix the problem. Here is the error message that I get when I try to install any package using pip3 (I get the same error when I use pip as well):

`Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 143, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 279, in run
    with self._build_session(options) as session:
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 79, in _build_session
    insecure_hosts=options.trusted_hosts,
  File "/usr/lib/python3/dist-packages/pip/_internal/download.py", line 337, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/usr/lib/python3/dist-packages/pip/_internal/download.py", line 100, in user_agent
    zip(["name", "version", "id"], distro.linux_distribution()),
  File "/usr/share/python-wheels/distro-1.3.0-py2.py3-none-any.whl/distro.py", line 120, in linux_distribution
    return _distro.linux_distribution(full_distribution_name)
  File "/usr/share/python-wheels/distro-1.3.0-py2.py3-none-any.whl/distro.py", line 675, in linux_distribution
    self.version(),
  File "/usr/share/python-wheels/distro-1.3.0-py2.py3-none-any.whl/distro.py", line 735, in version
    self.lsb_release_attr('release'),
  File "/usr/share/python-wheels/distro-1.3.0-py2.py3-none-any.whl/distro.py", line 892, in lsb_release_attr
    return self._lsb_release_info.get(attribute, '')
  File "/usr/share/python-wheels/distro-1.3.0-py2.py3-none-any.whl/distro.py", line 550, in __get__
    ret = obj.__dict__[self._fname] = self._f(obj)
  File "/usr/share/python-wheels/distro-1.3.0-py2.py3-none-any.whl/distro.py", line 998, in _lsb_release_info
    stdout = subprocess.check_output(cmd, stderr=devnull)
  File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.`

Here are the results of running pip3 -V:

pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)

I don't know if that information would be useful, but I figured that I would include it. Once again, I would really appreciate any help in understanding the error and fixing the issue. Thanks for any responses in advance!

2 Answers 2

2

So I was able to fix the issue by uninstalling python and autoremoving and then reinstalling python:

sudo apt-get purge python python3 python-pip python3-pip

sudo apt autoremove

sudo apt-get install python python3 python-pip python3-pip

Unfortunately, I still don't know exactly what caused the issue, but this approach did solve the issue for me.

1
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year.
    – Ingo
    Jun 24, 2020 at 14:09
1

You must reinstall everything that has connection with python2 and python3. This can fix your problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.