Bug 1932713

Summary: python-pip: Improve error message when pip uninstalling RPM-installed package
Product: Red Hat Enterprise Linux 9 Reporter: Meina Li <meili>
Component: python-pipAssignee: Charalampos Stratakis <cstratak>
Status: CLOSED ERRATA QA Contact: Lukáš Zachar <lzachar>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.0CC: cstratak, jil, mhroncok, pviktori, torsava
Target Milestone: pre-dev-freezeKeywords: Rebase, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-pip-21.2.3-2.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 15:37:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Meina Li 2021-02-25 01:31:07 UTC
Description of problem:
Uninstall chardet failed

Version-Release number of selected component (if applicable):
kernel-5.11.0-1.el9.x86_64
python3-chardet-4.0.0-1.el9.noarch

How reproducible:
100%

Steps to Reproduce:
# pip list | grep chardet
chardet          4.0.0
# pip uninstall chardet
Found existing installation: chardet 4.0.0
ERROR: Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 189, in _main
    status = self.run(options, args)
  File "/usr/lib/python3.9/site-packages/pip/_internal/commands/uninstall.py", line 87, in run
    uninstall_pathset = req.uninstall(
  File "/usr/lib/python3.9/site-packages/pip/_internal/req/req_install.py", line 658, in uninstall
    uninstalled_pathset = UninstallPathSet.from_dist(dist)
  File "/usr/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 541, in from_dist
    for path in uninstallation_paths(dist):
  File "/usr/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 74, in unique
    for item in fn(*args, **kw):
  File "/usr/lib/python3.9/site-packages/pip/_internal/req/req_uninstall.py", line 92, in uninstallation_paths
    r = csv.reader(dist.get_metadata_lines('RECORD'))
  File "/usr/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1432, in get_metadata_lines
    return yield_lines(self.get_metadata(name))
  File "/usr/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1420, in get_metadata
    value = self._get(path)
  File "/usr/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1616, in _get
    with open(path, 'rb') as stream:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.9/site-packages/chardet-4.0.0.dist-info/RECORD'

Actual results:
Uninstall chardet failed

Expected results:
Should uninstall chardet successfully.

Additional info:

Comment 1 Miro Hrončok 2021-02-25 10:21:27 UTC
pip-uninstalling rpm-installed packages should not work, that is expected.

The error message is cryptic, we have opened https://github.com/pypa/pip/issues/8954 already.

Comment 2 Li, Jin 2021-03-01 02:00:45 UTC
Hi Miro

In my opinion, the issue here is that if the custom migrate from RHEL8 to RHEL9, when the custom's environment need chardet < 4.0 (specified by requirement in python project), the installation will fail in RHEL9 while it works well on RHEL8. I do not think it is acceptable.

Comment 3 Miro Hrončok 2021-03-01 09:31:36 UTC
> I do not think it is acceptable.

I respectfully disagree. If this was not acceptable, we would not be bale to update any Python package ever and we would be stuck with the RHEL 8 versions for eternity.

If a customer specifies Python requirements in projects, such as "chardet < 4.0", they can use PyPI (or their internal package server) to fetch and install the packages into a virtual Python environment. RHEL offers only a very limited set of packages in a very limited set of versions (usually one version per package for a specific Python version).

Uninstalling system packages with pip and replacing them with custom versions isn't (and never was) a supported use case. In fact, users can brick their system when they do that.

Before we go any further: What **exactly** do you try to accomplish here? I don't think uninstalling chardet is the end goal here, is it?

Comment 4 Li, Jin 2021-03-05 07:55:06 UTC
Hi Miro,

Actually i can create a virtual env to install the pip package chardet, just a little curious about the system behavior change from RHEL8 to RHEL9. Feel free to close this bug since there's been a pip issue to track the log problem. Thanks for your explanation

Comment 5 Miro Hrončok 2021-05-05 14:44:15 UTC
Upstream PR: https://github.com/pypa/pip/pull/9949

Let's wait a bit for their feedback before we backport it.

Comment 6 Petr Viktorin (pviktori) 2021-06-16 12:28:36 UTC
It was merged upstream, so we can backport (or rebase after release)

Comment 7 Petr Viktorin (pviktori) 2021-06-16 12:30:54 UTC
It should first go in Fedora Rawhide and 34.

Comment 9 Charalampos Stratakis 2021-09-14 15:56:28 UTC
(In reply to Charalampos Stratakis from comment #8)
> PR: https://gitlab.com/redhat/centos-stream/rpms/python-pip/-/jobs/1589581440

Oos that was the CI link. Proper link: https://gitlab.com/redhat/centos-stream/rpms/python-pip/-/merge_requests/4

Comment 15 errata-xmlrpc 2022-05-17 15:37:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: python-pip), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:3908