'How to deal with this exception? 'ERROR: Cannot uninstall 'wrapt'. It is a distutils installed project etc.'

I am trying to update wrapt in order to update tensorflow 2.0 to its latest version but I am running into the following exception:

ERROR: Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

How can I deal with this?

For the full error message:

(base) D:\DIGITAL_LIBRARY\Jupyter_Notebook_Files>pip install wrapt --upgrade
Collecting wrapt
  Using cached https://files.pythonhosted.org/packages/23/84/323c2415280bc4fc880ac5050dddfb3c8062c2552b34c2e512eb4aa68f79/wrapt-1.11.2.tar.gz
Building wheels for collected packages: wrapt
  Building wheel for wrapt (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Alienware\\AppData\\Local\\Temp\\pip-install-4116x4uj\\wrapt\\setup.py'"'"'; __file__='"'"'C:\\Users\\Alienware\\AppData\\Local\\Temp\\pip-install-4116x4uj\\wrapt\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Alienware\AppData\Local\Temp\pip-wheel-yzv7oa9k' --python-tag cp36
       cwd: C:\Users\Alienware\AppData\Local\Temp\pip-install-4116x4uj\wrapt\
  Complete output (46 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.6
  creating build\lib.win-amd64-3.6\wrapt
  copying src\wrapt\decorators.py -> build\lib.win-amd64-3.6\wrapt
  copying src\wrapt\importer.py -> build\lib.win-amd64-3.6\wrapt
  copying src\wrapt\wrappers.py -> build\lib.win-amd64-3.6\wrapt
  copying src\wrapt\__init__.py -> build\lib.win-amd64-3.6\wrapt
  running build_ext
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\Alienware\AppData\Local\Temp\pip-install-4116x4uj\wrapt\setup.py", line 101, in <module>
      run_setup(with_extensions=True)
    File "C:\Users\Alienware\AppData\Local\Temp\pip-install-4116x4uj\wrapt\setup.py", line 71, in run_setup
      setup(**setup_kwargs_tmp)
    File "c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\distutils\dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\site-packages\wheel\bdist_wheel.py", line 202, in run
      self.run_command('build')
    File "c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "C:\Users\Alienware\AppData\Local\Temp\pip-install-4116x4uj\wrapt\setup.py", line 25, in run
      build_ext.run(self)
    File "c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\distutils\command\build_ext.py", line 308, in run
      force=self.force)
    File "c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\distutils\ccompiler.py", line 1031, in new_compiler
      return klass(None, dry_run, force)
    File "c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\distutils\cygwinccompiler.py", line 285, in __init__
      CygwinCCompiler.__init__ (self, verbose, dry_run, force)
    File "c:\program files (x86)\microsoft visual studio\shared\anaconda3_64\lib\distutils\cygwinccompiler.py", line 129, in __init__
      if self.ld_version >= "2.10.90":
  TypeError: '>=' not supported between instances of 'NoneType' and 'str'
  ----------------------------------------
  ERROR: Failed building wheel for wrapt
  Running setup.py clean for wrapt
Failed to build wrapt
Installing collected packages: wrapt
  Found existing installation: wrapt 1.10.11
ERROR: Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.


Solution 1:[1]

I fixed the same error using

pip install wrapt --upgrade --ignore-installed

Solution 2:[2]

I fixed that problem by:

conda remove --yes wrapt

then :

pip install --upgrade tensorflow

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Federico Rueda
Solution 2 Mohammed SALEM