EnvironmentError: Permission denied Using Python 3.7.4

I noticed that the python 3.7.4 container for building spaces fails due to a permission error when upgrading pip:

Specifically, at the step:

--> RUN pip install --no-cache-dir pip==22.3.1 &&     pip install --no-cache-dir         datasets         "huggingface-hub>=0.12.1" "protobuf<4" "click<8.1"
Collecting pip==22.3.1
  Downloading https://files.pythonhosted.org/packages/09/bd/2410905c76ee14c62baf69e3f4aa780226c1bbfc9485731ad018e35b0cb5/pip-22.3.1-py3-none-any.whl (2.1MB)
Installing collected packages: pip
  Found existing installation: pip 19.3
    Uninstalling pip-19.3:
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/bin/pip'

Any fix available? I know the 3.10 python containers are working, but I need 3.7 to support some legacy codebase I’d rather not update at the moment.

FWIW I noticed this is happening on 3.7.5 as well, but not 3.7.16