azurelinux icon indicating copy to clipboard operation
azurelinux copied to clipboard

Not able to upgrade pip from `python3-pip` package in Azure Linux 3

Open bebound opened this issue 1 year ago • 3 comments

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:

  1. tdnf install python3-pip
  2. python3 -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 avatar Oct 29 '24 07:10 bebound

@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

zcobol avatar Oct 29 '24 20:10 zcobol

--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.

bebound avatar Oct 30 '24 01:10 bebound

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.

elsaco avatar Oct 30 '24 03:10 elsaco

+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 avatar Dec 06 '24 19:12 annapankiewicz

@annapankiewicz can you help me understand the need to update pip vs using what's provided?

jperrin avatar Dec 14 '24 00:12 jperrin

@jperrin As described in the issue, what's the right way to upgrade the system pip?

bebound avatar Dec 16 '24 02:12 bebound

The same error here, skipping the pip upgrade for now.

RodriGoncaDeeployer avatar Mar 19 '25 17:03 RodriGoncaDeeployer