pip: Warning "There was an error checking the latest version of pip"
Description
Pip issues the warning message “WARNING: There was an error checking the latest version of pip” when running “pip list -o” on Python 3.10 running inside Windows 11.
If I run “pip list -o -vv”, the following stack trace is generated:
See below for error
Traceback (most recent call last):
File "C:\Development\Data_Science\Projects\semantic_qa\venv\lib\site-packages\pip\_internal\self_outdated_check.py", line 227, in pip_self_version_check
upgrade_prompt = _self_version_check_logic(
File "C:\Development\Data_Science\Projects\semantic_qa\venv\lib\site-packages\pip\_internal\self_outdated_check.py", line 188, in _self_version_check_logic
remote_version_str = state.get(current_time)
File "C:\Development\Data_Science\Projects\semantic_qa\venv\lib\site-packages\pip\_internal\self_outdated_check.py", line 76, in get
last_check = datetime.datetime.fromisoformat(self._state["last_check"])
ValueError: Invalid isoformat string: '2023-10-12T09:17:22Z'
Might this be the underlying cause? https://www.reddit.com/r/Python/comments/163ugsm/psa_as_of_python_311_datetimefromisoformat/
Expected behavior
No warning message appears
pip version
23.3
Python version
3.10
OS
Windows 11
How to Reproduce
- In Windows, create and activate a new virtualenv
- Upgrade pip to version 23.3 running “python.exe -m pip install pip==23.3”
- Run “pip list -o” and get the WARNING: There was an error checking the latest version of pip.
- Run “pip list -o -vv” and get the warning, plus the stack trace
Output
WARNING: There was an error checking the latest version of pip.
See below for error
Traceback (most recent call last):
File "C:\Development\test_pip\venv\lib\site-packages\pip\_internal\self_outdated_check.py", line 227, in pip_self_version_check
upgrade_prompt = _self_version_check_logic(
File "C:\Development\test_pip\venv\lib\site-packages\pip\_internal\self_outdated_check.py", line 188, in _self_version_check_logic
remote_version_str = state.get(current_time)
File "C:\Development\test_pip\venv\lib\site-packages\pip\_internal\self_outdated_check.py", line 76, in get
last_check = datetime.datetime.fromisoformat(self._state["last_check"])
ValueError: Invalid isoformat string: '2023-10-15T23:25:56Z'
Code of Conduct
- I agree to follow the PSF Code of Conduct.
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Reactions: 56
- Comments: 24 (12 by maintainers)
pip 23.3.1 has been released with the fix for this.
Hi folks. Please don’t add “me too” style comments here. If you are affected by this issue, add a 👍🏽 reaction to the first comment.
pip cache purge
doesn’t completely purge my pip cache:However,
rm -rf ~/.cache/pip
does completely purge the cache and it also fixes the pip version check warning (error).Here are the results of running
pip install --upgrade pip
first after runningpip cache purge
and then after runningrm -rf ~/.cache/pip
:pip cache purge
:rm -rf ~/.cache/pip
:You can use
pip cache info
to get details andpip cache purge
to clear the cache, no need to hunt for the location 🙂Another workaround is to delete the pip cache - on Linux this is in
~/.cache/pip
. Pip 23.3 works fine with no warning after you do this.This should now be fixed on
main
, thanks to #12363.The underlying issue is that a key-value pair in a JSON object, placed in a JSON file in that directory contains a value that can’t be parsed by this version of pip, when it has been generated by a sufficiently old version of pip.
Deleting the directory removes specifically the problematic files, which resolves this issue.
FWIW, the targeted cleanup step here is to delete the selfcheck directory within the cache.
Any idea when we can expect a release with this code in it?
As a workaround, setting a
PIP_DISABLE_PIP_VERSION_CHECK=1
environment variable may help.