title: pip upgrading within the Python Alpine image: ERROR: Could not install packages due to an OSError: [Errno 39] Directory not empty: 'urllib3'
body: <p>When I use pip to install stuff it tells me</p>
  <pre><code>WARNING: You are using pip version 22.0.4; however, version 22.2 is available.
  You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
  </code></pre>
  <p>However when I try to install it I get a problem</p>
  <pre><code>/ # /usr/local/bin/python -m pip install --upgrade pip
  Requirement already satisfied: pip in /usr/local/lib/python3.7/site-packages (22.0.4)
  Collecting pip
    Downloading pip-22.2-py3-none-any.whl (2.0 MB)
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 21.2 MB/s eta 0:00:00
  Installing collected packages: pip
    Attempting uninstall: pip
      Found existing installation: pip 22.0.4
      Uninstalling pip-22.0.4:
  ERROR: Could not install packages due to an OSError: [Errno 39] Directory not empty: 'urllib3'
  </code></pre>
  <p>The weird thing here is this is <em>easily</em> reproducable. I'm using the <code>python:3.7-alpine</code> image.</p>
  <p>You can see this error like this,</p>
  <pre><code>podman run -ti python:3.7-alpine /usr/local/bin/python -m pip install --upgrade pip
  </code></pre>
  <p>What the right way to upgrade Python 3.7 using the Alpine image, such that I don't get this error,</p>
  <blockquote>
  <p>ERROR: Could not install packages due to an OSError: [Errno 39] Directory not empty: 'urllib3'</p>
  </blockquote>
  <p>You can see the <a href="https://github.com/docker-library/python/blob/957d539a9b50aba11e8af8687b5f7c2fbd25ee24/3.7/alpine3.16/Dockerfile" rel="nofollow noreferrer">Dockerfile to create the <code>python:3.7-alpine</code> image here</a></p>