Unicode error while upgrading any package through pip including pip

Hi there,
I have an issue with pip upgradation through terminal when im using the command :pip install --upgrade pip, I’m getting following error ,i’m using python version 3.12.1
WARNING: Cache entry deserialization failed, entry ignored
Collecting pip
WARNING: Cache entry deserialization failed, entry ignored
WARNING: Cache entry deserialization failed, entry ignored
Downloading pip-24.0-py3-none-any.whl.metadata (3.6 kB)
WARNING: Cache entry deserialization failed, entry ignored
WARNING: Cache entry deserialization failed, entry ignored
Downloading pip-24.0-py3-none-any.whl (2.1 MB)
---------------------------------------- 2.1/2.1 MB 5.6 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 23.3.2
ERROR: Exception:
Traceback (most recent call last):
File “C:\Users\sarankumar\AppData\Roaming\Python\Python312\site-packages\pip_internal\cli\base_command.py”, line 180, in exc_logging_wrapper
status = run_func(*args)
^^^^^^^^^^^^^^^
File “C:\Users\sarankumar\AppData\Roaming\Python\Python312\site-packages\pip_internal\cli\req_command.py”, line 245, in wrapper
return func(self, options, args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\sarankumar\AppData\Roaming\Python\Python312\site-packages\pip_internal\commands\install.py”, line 452, in run
installed = install_given_reqs(
^^^^^^^^^^^^^^^^^^^
File “C:\Users\sarankumar\AppData\Roaming\Python\Python312\site-packages\pip_internal\req_init_.py”, line 67, in install_given_reqs
uninstalled_pathset = requirement.uninstall(auto_confirm=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\sarankumar\AppData\Roaming\Python\Python312\site-packages\pip_internal\req\req_install.py”, line 724, in uninstall
uninstalled_pathset = UninstallPathSet.from_dist(dist)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\sarankumar\AppData\Roaming\Python\Python312\site-packages\pip_internal\req\req_uninstall.py”, line 534, in from_dist
for path in uninstallation_paths(dist):
File “C:\Users\sarankumar\AppData\Roaming\Python\Python312\site-packages\pip_internal\req\req_uninstall.py”, line 46, in unique
for item in fn(*args, **kw):
File “C:\Users\sarankumar\AppData\Roaming\Python\Python312\site-packages\pip_internal\req\req_uninstall.py”, line 72, in uninstallation_paths
entries = dist.iter_declared_entries()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\sarankumar\AppData\Roaming\Python\Python312\site-packages\pip_internal\metadata\base.py”, line 519, in iter_declared_entries
self._iter_declared_entries_from_record()
File “C:\Users\sarankumar\AppData\Roaming\Python\Python312\site-packages\pip_internal\metadata\base.py”, line 480, in _iter_declared_entries_from_record
text = self.read_text(“RECORD”)
^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\sarankumar\AppData\Roaming\Python\Python312\site-packages\pip_internal\metadata\importlib_dists.py”, line 192, in read_text
content = self.dist.read_text(str(path))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\sarankumar\AppData\Local\Programs\Python\Python312\Lib\importlib\metadata_init
.py", line 818, in read_text
return self._path.joinpath(filename).read_text(encoding=‘utf-8’)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\sarankumar\AppData\Local\Programs\Python\Python312\Lib\pathlib.py”, line 1028, in read_text
return f.read()
^^^^^^^^
File “”, line 322, in decode
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x9b in position 0: invalid start byte
WARNING: Cache entry deserialization failed, entry ignored

what ever the way i’m trying to solve the issue,I’m not able to solve this please kindly help with this issue,Thanks in advance

Try:

py -m pip install --upgrade pip

Hi Paul thank you reply,
I have already tried it I’m getting same issue
Please suggest alternate solution if any

First try uninstalling pip from your system explicitly. Note that when you were attempting to upgrade pip, it was already attempting to do so (from trace above):

attempted_uninstalling_pip

Here, were just going to do it explicitly.

First try:

  1. pip uninstall pip

if that doesn’t work:

  1. Try uninstalling pip manually from its current location. On my Windows based system, it is located here: C:\users\your_username\AppData\Local\pip

Then re-install pip