8

I'm using python 3.8.2 on ubuntu on windows 10. I'm reading an OOP pdf and I'm at the third-party libraries section. It says that pip doesn't come with python, but python 3.4 contains a useful tool called ensurepip, which will install it: python -m ensurepip.

But when I press enter, it says no module named ensurepip

/usr/bin/python3: No module named ensurepip

So I thought that I already have pip so I tried to install pygame with pip but it says there's no module named pip. What am I doing wrong?

Thanks.

1 Answers1

24

The module ensurepip is part of Python's standard library. It should be there. You say you're on Windows, but then you show /usr/bin/python3 in your question, which is obviously not a Windows path (rather Linux).

My assumption is that you might be using WSL (or WSL2), which is actually Linux running on Windows (without going into details). By default WSL runs a Ubuntu distribution. This distribution (and other Debian-related distributions) typically breaks up Python and its standard library in multiple pieces.

So you might need to install an additional system package, I believe it could be the python3-venv system package that contains the Python ensurepip module in your case:

sudo apt-get install python3-venv
sinoroc
  • 18,409
  • 2
  • 39
  • 70
  • Why can't I use pip to install pygame? The sudo apt-get install python3-venv worked but I still can't use pip. Why? –  Jul 26 '20 at 14:36
  • running from Elementary OS I got `ensurepip is disabled in Debian/Ubuntu for the system python. (...) or make sure to only use it in virtual environments.` message with some warnings in `(...)` about local system instllations. Then I create a virtual environment (https://docs.python.org/3/library/venv.html) on the project I'm working and then ran pip virtually as module (it is already there in venv). Work well also. – Enrique René Sep 07 '21 at 14:38