Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run pip on python 3.11

I'm on a fresh Ubuntu 20.4 install (or really, a reinstall, as I messed up some things and had to start over; everything except /home has been reformatted, so if there is an issue with remnants, it's there), with python 3.8 included. However, I want to run python 3.11, since that's the newest. I follow this guide, which basically amounts to

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update 
sudo apt install python3.11

coupled with

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.11 1

I now, at least as far as I know, run version 3.11 as default. However, i run into problems with pip. Running just pip --version (or pip3 --version) returns

pip 21.3.1 from /home/usrname/.local/lib/python3.8/site-packages/pip (python 3.8)

In addition, when I run python -m pip (which now uses the 3.11 version) I get

/usr/bin/python: No module named pip

If I revert back to python3.8 -m pip, I get the welcome message with all the different commands pip has to offer. So that works fine.

(Because deadsnakes has version 3.11 marked as alpha at the moment, I also tried with 3.10. Same result there: no pip.)

I was under the impression that pip came bundled with python as default. How can I give my newer version of python a pip to play with?

like image 629
Arthur Avatar asked Sep 06 '25 11:09

Arthur


1 Answers

I installed Python3.11 from the deadsnakes ppa, it doesn't come with ensurepip or pip, and the bootstrap script initially fails as it depends on distutils. I solved this by installing the optional distutils package and then bootstrapping.

apt install python3.11 python3.11-distutils
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
like image 186
mfurseman Avatar answered Sep 08 '25 05:09

mfurseman