PythonMastery
reference 3 min read · lesson 77 of 80 in Errors

'pip' is not recognized as an internal or external command

1 · The lesson

read

What this error means

The terminal looked for a program called pip and didn't find it. pip is the tool that installs Python packages. It is installed together with Python, but the pip command lives in a separate folder (Scripts on Windows), and that folder often isn't on your PATH, the list of folders the terminal searches. Python itself may work fine. This is not a Python error, because neither Python nor pip ever started.

When you see it

In Command Prompt:

text
C:\Users\Ada> pip install requests
'pip' is not recognized as an internal or external command,
operable program or batch file.

In PowerShell:

text
PS C:\Users\Ada> pip install requests
pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

On macOS and Linux the same problem reads zsh: command not found: pip or bash: pip: command not found. Ubuntu may add Command 'pip' not found, but can be installed with: sudo apt install python3-pip.

Why it happens

1. The Scripts folder isn't on PATH. The Windows installer from python.org has a box, Add python.exe to PATH, which is not ticked by default. Without it, neither python nor pip is found. Even with it ticked, some setups add the Python folder but not its Scripts folder, so python works and pip doesn't.

2. On macOS and Linux the command is pip3. Many systems only install pip3 and python3. Plain pip and python may not exist at all, or may point to something else.

3. pip isn't installed for that Python. On Debian and Ubuntu, pip is a separate system package, python3-pip. Some custom or minimal Python installs leave pip out too.

4. The terminal was open during the install. A terminal reads PATH once, when it opens. If you installed Python, or changed PATH, while it was open, it still has the old list.

How to fix it

Run pip through Python. This works almost everywhere and is the recommended way anyway. Instead of pip, write py -m pip on Windows, or python3 -m pip on macOS and Linux:

text
py -m pip install requests
bash
python3 -m pip install requests

-m pip means "run the pip module with this Python". It doesn't depend on the Scripts folder being on PATH. It also installs into exactly the Python you named, which avoids the classic problem where pip installs into one Python and your code runs with another.

Inside a virtual environment, plain pip works. Activating a virtual environment puts its own pip first on PATH:

text
py -m venv .venv
.venv\Scripts\activate
pip install requests

If py -m pip says No module named pip, pip itself is missing. Python can install it:

text
py -m ensurepip --upgrade

On Debian and Ubuntu, install the system package instead: sudo apt install python3-pip.

If you want the plain pip command on Windows, run the python.org installer again, choose Modify, and tick Add Python to environment variables. Then close and reopen the terminal. To see which folder needs to be on PATH, ask Python:

python
import sysconfig
print(sysconfig.get_path("scripts"))   # the folder that holds pip.exe

When you'd see this in real code

  • A tutorial says pip install pandas, and you are on a fresh Windows install where Python came from python.org with the default options.
  • In VS Code, the terminal panel was opened before Python was installed. Closing that terminal and opening a new one fixes it.
  • On a Mac, pip install fails but pip3 install works, because the system only provides pip3.
  • In a Dockerfile based on a minimal Debian or Ubuntu image, RUN pip install ... fails until python3-pip is installed or a python: base image is used.

See Also

Found this useful? Share it with a friend who’s learning Python.