Not able to upgrade pip from `python3-pip` package in Azure Linux 3
Describe the bug
Not able to use python3 -m pip install -U pip to upgrade pip from python3-pip package in Azure Linux 3.
I'm able to do so in Mariner2.0 and other distros.
To Reproduce Steps to reproduce the behavior:
tdnf install python3-pippython3 -m pip install -U pip
Expected behavior Update pip
Screenshots
root [ / ]# python3 -m pip install -U pip
Requirement already satisfied: pip in /usr/lib/python3.12/site-packages (24.2)
Collecting pip
Downloading pip-24.3.1-py3-none-any.whl.metadata (3.7 kB)
Downloading pip-24.3.1-py3-none-any.whl (1.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 5.7 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 24.2
error: uninstall-no-record-file
× Cannot uninstall pip 24.2
╰─> The package's contents are unknown: no RECORD file was found for pip.
hint: The package was installed by rpm. You should check if it can uninstall the package.
@bebound pip install --upgrade --ignore-installed pip works:
zcobol@azure-166 [ ~ ]$ sudo pip install --upgrade pip
Requirement already satisfied: pip in /usr/lib/python3.12/site-packages (24.2)
Collecting pip
Using cached pip-24.3.1-py3-none-any.whl.metadata (3.7 kB)
Using cached pip-24.3.1-py3-none-any.whl (1.8 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 24.2
error: uninstall-no-record-file
× Cannot uninstall pip 24.2
╰─> The package's contents are unknown: no RECORD file was found for pip.
hint: The package was installed by rpm. You should check if it can uninstall the package.
and with --ignore-installed argument:
zcobol@azure-166 [ ~ ]$ sudo pip install --upgrade --ignore-installed pip
Collecting pip
Using cached pip-24.3.1-py3-none-any.whl.metadata (3.7 kB)
Using cached pip-24.3.1-py3-none-any.whl (1.8 MB)
Installing collected packages: pip
Successfully installed pip-24.3.1
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
zcobol@azure-166 [ ~ ]$ pip list
Package Version
---------- -------
pip 24.3.1
setuptools 69.0.3
--ignore-installed does not remove the files from 24.2. It only overwrites the files in new version.
This might be a workaround, but the usual method to upgrade a package is to uninstall the previous version and install the new one.
The python3-pip RPM package is missing the RECORD file. However, PEP 627 states that the RECORD file is optional:
The RECORD file is made optional. Not all tools can easily generate a list of installed files
in a Python-specific format.
Specifically, the RECORD file is unnecessary when projects are installed by a Linux system packaging system,
which has its own ways to keep track of files, uninstall them or check their integrity. Having to keep a RECORD
file in sync with the disk and the system package database would be unreasonably fragile, and no RECORD file
is better than one that does not correspond to reality.
More info at https://peps.python.org/pep-0627/#optional-record-file
Because the INSTALLER file is present but no RECORD the rpm tool doesn't know what to uninstall, thus the error. More info about the error message:
When dist-info/INSTALLER is present and contains some useful information,
the info is included in the error message instead:
ERROR: Cannot uninstall foobar 0.1, RECORD file not found. Hint: The package was installed by rpm.
+1, also running into this.
##[error]#6 [6/8] RUN python3 -m pip install --upgrade pip
##[error]#6 0.795 Looking in indexes: https://build:***@pkgs.dev.azure.com/*******/*******/_packaging/*******/pypi/simple
##[error]#6 0.795 Requirement already satisfied: pip in /usr/lib/python3.12/site-packages (24.2)
##[error]#6 0.994 Collecting pip
##[error]#6 1.127 Downloading https://pkgs.dev.azure.com/*******/*******/_packaging/*******/pypi/download/pip/24.3.1/pip-24.3.1-py3-none-any.whl (1.8 MB)
##[error]#6 1.190 Installing collected packages: pip
##[error]#6 1.191 Attempting uninstall: pip
##[error]#6 1.194 Found existing installation: pip 24.2
##[error]#6 1.426 error: uninstall-no-record-file
##[error]#6 1.426
##[error]#6 1.426 × Cannot uninstall pip 24.2
##[error]#6 1.426 ╰─> The package's contents are unknown: no RECORD file was found for pip.
##[error]#6 1.426
##[error]#6 1.426 hint: The package was installed by rpm. You should check if it can uninstall the package.
##[error]#6 ERROR: process "/bin/sh -c python3 -m pip install --upgrade pip" did not complete successfully: exit code: 1
##[error]------
##[error] > [6/8] RUN python3 -m pip install --upgrade pip:
##[error]#6 1.190 Installing collected packages: pip
##[error]#6 1.191 Attempting uninstall: pip
##[error]#6 1.194 Found existing installation: pip 24.2
##[error]#6 1.426 error: uninstall-no-record-file
##[error]#6 1.426
##[error]#6 1.426 × Cannot uninstall pip 24.2
##[error]#6 1.426 ╰─> The package's contents are unknown: no RECORD file was found for pip.
##[error]#6 1.426
##[error]#6 1.426 hint: The package was installed by rpm. You should check if it can uninstall the package.
##[error]------
##[error]Dockerfile:39
@annapankiewicz can you help me understand the need to update pip vs using what's provided?
@jperrin As described in the issue, what's the right way to upgrade the system pip?
The same error here, skipping the pip upgrade for now.