Field Note

Field Notes of April 4th 2024

python pip install ensurepip ppa:deadsnakes/ppa
Posted on Thursday, April the 4th 2024
1 min read

That pip may also be installed using the ensurepip module bundle with Python

python -m ensurepip --upgrade
The ensurepip module is not included in the official Python 3.12 apt package (ppa:deadsnakes/ppa) and cannot not be used if we install via apt.

How to install pip when using the ppa:deadsnakes/ppa repo for apt to install Python 3.12

curl --location \  
  --silent \  
  --output /tmp/get-pip.py \  
  https://bootstrap.pypa.io/get-pip.py && \
python -m venv --without-pip .venv && \
source .venv/bin/activate && \
export PIP_VERSION=24.0 && \
python /tmp/get-pip.py "pip==${PIP_VERSION}"
# ... do stuff in your venv
deactivate && \
rm /tmp/get-pip.py
Note that we use the --without-pip option with python -m venv because otherwise, the venv module would call python -m ensurepip. This module is, however, not installed in the ppa:deadsnakes/ppa Python 3.12 apt package and python -m venv will fail. We may install pip using the get-pip.py script though, as shown above.
friedrichkurz.me

© 2025 Friedrich Kurz

Privacy Policy