title: Pip is broken after error uninstalling toml package, what steps can I take to reset it?
body: <p>I was uninstalling my locally installed pylint package and its dependencies not required by other packages via pip, and in the process seem to have completely sunk pip on my system (Manjaro Linux), particularly while uninstalling the toml package.</p>
  <p>toml was one of the dependencies for pylint reported by <code>pip show pylint</code>, and when <code>pip show toml</code> reported no packages required it, I ran <code>pip uninstall toml</code>, and, falsely assuming it was a local package, forgot to prefix the command with <code>sudo</code>, which lead to the exception:</p>
  <pre><code>ERROR: Exception:
  Traceback (most recent call last):
    File &quot;/usr/lib/python3.8/shutil.py&quot;, line 788, in move
      os.rename(src, real_dst)
  OSError: [Errno 18] Invalid cross-device link: '/usr/lib/python3.8/site-packages/toml' -&gt; '/tmp/pip-uninstall-hnohl3wr'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;/usr/lib/python3.8/site-packages/pip/_internal/cli/base_command.py&quot;, line 188, in _main
      status = self.run(options, args)
    File &quot;/usr/lib/python3.8/site-packages/pip/_internal/commands/uninstall.py&quot;, line 85, in run
      uninstall_pathset = req.uninstall(
    File &quot;/usr/lib/python3.8/site-packages/pip/_internal/req/req_install.py&quot;, line 676, in uninstall
      uninstalled_pathset.remove(auto_confirm, verbose)
    File &quot;/usr/lib/python3.8/site-packages/pip/_internal/req/req_uninstall.py&quot;, line 394, in remove
      moved.stash(path)
    File &quot;/usr/lib/python3.8/site-packages/pip/_internal/req/req_uninstall.py&quot;, line 283, in stash
      renames(path, new_path)
    File &quot;/usr/lib/python3.8/site-packages/pip/_internal/utils/misc.py&quot;, line 349, in renames
      shutil.move(old, new)
    File &quot;/usr/lib/python3.8/shutil.py&quot;, line 800, in move
      rmtree(src)
    File &quot;/usr/lib/python3.8/shutil.py&quot;, line 715, in rmtree
      _rmtree_safe_fd(fd, path, onerror)
    File &quot;/usr/lib/python3.8/shutil.py&quot;, line 672, in _rmtree_safe_fd
      onerror(os.unlink, fullname, sys.exc_info())
    File &quot;/usr/lib/python3.8/shutil.py&quot;, line 670, in _rmtree_safe_fd
      os.unlink(entry.name, dir_fd=topfd)
  PermissionError: [Errno 13] Permission denied: 'decoder.py'
  
  </code></pre>
  <p>I then just ran <code>sudo pip uninstall toml</code> which reported success. However, all subsequent attempts at installing, uninstalling or upgrading any packages via pip, currently on my system or not, have been met with the following error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/usr/bin/pip&quot;, line 33, in &lt;module&gt;
      sys.exit(load_entry_point('pip==20.1.1', 'console_scripts', 'pip')())
    File &quot;/usr/lib/python3.8/site-packages/pip/_internal/cli/main.py&quot;, line 73, in main
      command = create_command(cmd_name, isolated=(&quot;--isolated&quot; in cmd_args))
    File &quot;/usr/lib/python3.8/site-packages/pip/_internal/commands/__init__.py&quot;, line 104, in create_command
      module = importlib.import_module(module_path)
    File &quot;/usr/lib/python3.8/importlib/__init__.py&quot;, line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1014, in _gcd_import
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 991, in _find_and_load
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 975, in _find_and_load_unlocked
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 671, in _load_unlocked
    File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 783, in exec_module
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 219, in _call_with_frames_removed
    File &quot;/usr/lib/python3.8/site-packages/pip/_internal/commands/install.py&quot;, line 24, in &lt;module&gt;
      from pip._internal.cli.req_command import RequirementCommand, with_cleanup
    File &quot;/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.py&quot;, line 21, in &lt;module&gt;
      from pip._internal.req.constructors import (
    File &quot;/usr/lib/python3.8/site-packages/pip/_internal/req/__init__.py&quot;, line 12, in &lt;module&gt;
      from .req_install import InstallRequirement
    File &quot;/usr/lib/python3.8/site-packages/pip/_internal/req/req_install.py&quot;, line 31, in &lt;module&gt;
      from pip._internal.pyproject import load_pyproject_toml, make_pyproject_path
    File &quot;/usr/lib/python3.8/site-packages/pip/_internal/pyproject.py&quot;, line 8, in &lt;module&gt;
      from pip._vendor import six, toml
  ImportError: cannot import name 'toml' from 'pip._vendor' (/usr/lib/python3.8/site-packages/pip/_vendor/__init__.py)
  </code></pre>
  <p>The same error is also reported with <code>pip freeze</code> and <code>pip list</code>.</p>
  <p>Was toml actually a major <code>pip</code> dependency but just not being reported as such? Is anyone familiar enough with the architecture of pip to know how I might clean up my installation? I would be okay removing all pip packages and just trying to reset my system if I could avoid borking it by removing python scripts and libs needed by the OS, but seeing as the <code>pip list/freeze</code> and <code>pip uninstall</code> commands aren't working anymore I'm not sure how I would do so. Any help here would be greatly appreciated.</p>