That pip may also be installed using the ensurepip
module bundle with Python
python -m ensurepip --upgrade
Pip documentation This module seems to not be included in the official Python 3.12
apt
package (ppa:deadsnakes/ppa
) and may not be used if we use that package.
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 withpython -m venv
because otherwise, thevenv
module would callpython -m ensurepip
. This module is, however, not installed in theppa:deadsnakes/ppa
Python 3.12apt
package andpython -m venv
will fail. We may installpip
using theget-pip.py
script though, as shown above.