Description of problem: Using get-pip.py [1] on Fedora 34 when pip is already installed you get ---- 2021-08-02 03:54:25.718 | + tools/install_pip.sh:install_get_pip:92 : sudo -H -E python3.9 /opt/stack/devstack/files/get-pip.py 2021-08-02 03:54:29.721 | Looking in indexes: https://mirror.kna1.airship-citycloud.opendev.org/pypi/simple, https://mirror.kna1.airship-citycloud.opendev.org/wheel/fedora-34-x86_64 2021-08-02 03:54:30.485 | Collecting pip 2021-08-02 03:54:30.489 | Downloading https://mirror.kna1.airship-citycloud.opendev.org/pypifiles/packages/8a/d7/f505e91e2cdea53cfcf51f4ac478a8cd64fb0bc1042629cedde20d9a6a9b/pip-21.2.2-py3-none-any.whl (1.6 MB) 2021-08-02 03:54:30.698 | Collecting wheel 2021-08-02 03:54:30.746 | Downloading https://mirror.kna1.airship-citycloud.opendev.org/pypifiles/packages/65/63/39d04c74222770ed1589c0eaba06c05891801219272420b40311cd60c880/wheel-0.36.2-py2.py3-none-any.whl (35 kB) 2021-08-02 03:54:31.023 | Installing collected packages: wheel, pip 2021-08-02 03:54:31.066 | Attempting uninstall: pip 2021-08-02 03:54:31.067 | Found existing installation: pip 21.0.1 2021-08-02 03:54:31.068 | ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/usr/lib/python3.9/site-packages/pip-21.0.1.dist-info/RECORD' ---- This was reported at [2] and closed without resolution. This has worked basically forever and is listed as a supported installation method at [3]. At the very least, this should fail with something other than a backtrace ... [1] https://pip.pypa.io/en/stable/installation/#get-pip-py [2] https://github.com/pypa/pip/issues/9904 [3] https://pip.pypa.io/en/stable/installation/
What are you trying to accomplish by running `sudo ... get-pip.py` when pip is already installed and what would you expect to happen in that case instead? Note that after https://github.com/pypa/pip/pull/9949 you should see a better error message.
Note that [3] explicitly says: """If your Python environment does not have pip installed, there are 2 mechanisms to install pip supported directly by pip’s maintainers ...""" So using get-pip.py when you already have pip installed is *not* a supported installation method. Also note that even without pip already installed, the installation method described at [3] does not involve using sudo at all. Using `sudo pip` (or in this case `sudo ... get-pip.py`) will eventually brick your system, is is a disaster waiting for happen. Never ever ever ever use `sudo pip` on Fedora (or RHEL). The pip upstream maintainers in [2] said """Don’t use get-pip.py against your system Python, it’s going to break a lot of stuff and you will regret it.""" and I couln't agree more. Anyway, I agree that the error message here is weird. Once get-pip.py is updated to 21.2 pip, you should get: $ sudo python3 get-pip.py Collecting pip Downloading pip-x.y.z-py3-none-any.whl (1.6 MB) |████████████████████████████████| 1.6 MB 2.4 MB/s Collecting setuptools Downloading setuptools-z.y.z-py3-none-any.whl (819 kB) |████████████████████████████████| 819 kB 4.0 MB/s Collecting wheel Downloading wheel-x.y.z-py2.py3-none-any.whl (35 kB) Installing collected packages: wheel, setuptools, pip Attempting uninstall: pip Found existing installation: pip x.y.z ERROR: Cannot uninstall pip x.y.z, RECORD file not found. Hint: The package was installed by rpm.
(In reply to Miro Hrončok from comment #2) > Using `sudo pip` (or in > this case `sudo ... get-pip.py`) will eventually brick your system, is is a > disaster waiting for happen. Never ever ever ever use `sudo pip` on Fedora > (or RHEL). Well we have been using this in Openstack Devstack based testing for many, many years ... The problem has usually been that we have tickled some sort of pip/setuptools bug and we get a fix incorporated there, but need to run the upstream pip to keep thing going in the mean time until the package is available. Once upon a time, installing via get-pip then installing python3-pip would mean RPM would come in and overwrites pip; but it's separated into /usr/local/... these days. This is why we pre-install python3-pip (and put it on hold in the package manager) and then run get-pip over the top. I know virtual environments ... but this is not so easy when you have a decade+ of tests built up that assume a complex multi-project layout like Openstack. If I touch the RECORD file it actually does the right thing anyway --- [root@fedora-34-rax-dfw-0025732028 ~]# touch /usr/lib/python3.9/site-packages/pip-21.0.1.dist-info/RECORD [root@fedora-34-rax-dfw-0025732028 ~]# python3 ./get-pip.py Collecting pip Using cached pip-21.2.2-py3-none-any.whl (1.6 MB) Installing collected packages: pip Attempting uninstall: pip Found existing installation: pip 21.0.1 Uninstalling pip-21.0.1: Successfully uninstalled pip-21.0.1 Successfully installed pip-21.2.2 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv [root@fedora-34-rax-dfw-0025732028 ~]# pip --version pip 21.2.2 from /usr/local/lib/python3.9/site-packages/pip (python 3.9) --- pip puts things in /usr/local/... and it does work as you expect, with things installed via the global pip overriding packages. I bet a lot of container builds do similar things too, where they are assuming they own the system and just set it up to do one particular thing. I think it would be good if the RPM package didn't make itself stop the global installation of pip if possible.
> Well we have been using this in Openstack Devstack based testing for many, many years ... Yes. So were many others, until they were hit. Hence, the "missing RECORD prevents this" thing was invented. Sure, it breaks your use case, but it prevents bricked systems. See the "WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager." line in he log you've pasted? It is there for a reason. Anyway: You can upgrade pip with the rpm installed pip if needed. You just cannot use `sudo get-pip.py` when you have python3-pip installed. Using `sudo get-pip.py` over the rpm-installed pip is not supported: - pip upstream does not support it - Fedora pip maintainers do not support it The get-pip.py script is intended for systems where pip is not yet available. It is not indeed to work on any system. If you touch RECORD, it might work now, but it might break again in the future. Please, don't pile unsupported things on top of other unsupported things. Those are the supported alternatives you could do instead, in order from the most preferred to the least: Best options: 1) use virtual environments (I know you say it is not easy, but this is still the most supported option) 2) use RPM installed pip only and report bugs to Fedora if you need to backport a fix (that way you can sometimes even have the fix sooner than upstream makes a release) Somewhat working options (with possible corner case problems for system packages not using `python3 -s` in the shebang): 3) use `python3 -m ensurepip` and/or `python3 -m pip install --upgrade pip` as regular user, not as root 4) use `get-pip.py` as regular user, not as root Dangerous, but still somewhat working options (until they brick your system): 4) use `sudo python3 -m ensurepip` and/or `sudo python3 -m pip install --upgrade pip` 5) Uninstall python3-pip RPM, use `sudo get-pip.py` only (works, but is not necessary at all) > I think it would be good if the RPM package didn't make itself stop the global installation of pip if possible. It doesn't stop "global installation of pip" -- it only stops pip from uninstalling the system managed pip. The get-pip.py script tries to remove files owned by the RPM package and that should never happen. We have a patch downstream for pip: https://src.fedoraproject.org/rpms/python-pip/blob/f34/f/remove-existing-dist-only-if-path-conflicts.patch If this is upstreamed, the get-pip.py might not attempt to uninstall the files owned by python3-pip. We can certainly try to work on that.
Ian, are any of those options helpful to you?
Thank you for engaging with this report. I've lived through all sorts of pip changes in this area and will live through another one :) I really don't think the situation is so dire these days, as it seems that get-pip.py installs into /usr/local/... and remains separate to the system installed packages. It's just that it is trying to uninstall the packaged version, which it doesn't really have to do. I don't really expect much for the OpenStack devstack case, that is very much a legacy application. I will be surprised though if more people don't start hitting this when building containers in the future, where I think this might be more common to just get something shoved on a system. I think perhaps it recently changed in Fedora, but uninstalling pip on centos8 also removes the user python (but not the underlying python3.6 system one) so that's not an option there. The ship has probably sailed on this, and a better error message might be as good as it gets. If nobody else is brining this up, then maybe we are the only people who care. Feel free to close, or leave for discussion; and hello to any future people searching about why this installed failed :)
Error message fixed in Rawhide: [root@rawhide-containter /]# python3 get-pip.py Collecting pip Downloading pip-21.2.4-py3-none-any.whl (1.6 MB) |████████████████████████████████| 1.6 MB 3.0 MB/s Collecting wheel Downloading wheel-0.37.0-py2.py3-none-any.whl (35 kB) Installing collected packages: wheel, pip Attempting uninstall: pip Found existing installation: pip 21.2.3 ERROR: Cannot uninstall pip 21.2.3, RECORD file not found. Hint: The package was installed by rpm. Fixing for f34 is tracked separately. Sorry for the churn; hopefully it'll be for the best in the long run.
FTR the line is coming from upstream pip, so Fedora version should not be relevant: Fedora 34: <mock-chroot> sh-5.1# python3 get-pip.py Collecting pip Downloading pip-21.2.4-py3-none-any.whl (1.6 MB) |████████████████████████████████| 1.6 MB 2.3 MB/s Collecting setuptools Downloading setuptools-57.4.0-py3-none-any.whl (819 kB) |████████████████████████████████| 819 kB 3.5 MB/s Collecting wheel Downloading wheel-0.37.0-py2.py3-none-any.whl (35 kB) Installing collected packages: wheel, setuptools, pip Found existing installation: pip 21.0.1 ERROR: Cannot uninstall pip 21.0.1, RECORD file not found. Hint: The package was installed by rpm.