DEV Community

Bartłomiej Stefański
Bartłomiej Stefański

Posted on • Originally published at bstefanski.com on

🤖 Installing Pip on macOS

In this blog post, I'll discuss a situation where I wanted to install a module using pip (the package installer for Python) but encountered an unexpected error: zsh: command not found: pip. This was quite surprising, as I assumed that Python, along with pip, was installed by default on macOS.

As it turns out, while Python is indeed installed by default on macOS, pip is not, and you'll need to download it separately. Additionally, the downloaded version is pip3, so you'll have to create an alias for pip since some tools or documentation still reference the older command.

To accomplish this, you can use the following one-liner:


python3 -m ensurepip && echo 'alias pip=pip3' >>~/.bash\_profile && source ~/.bash\_profile

Enter fullscreen mode Exit fullscreen mode

This command does the following:

  • Installs pip directly from the Python3 library
  • Adds an alias pip -> pip3 to your ~/.bash_profile, ensuring that you don't have to recreate the alias every time you restart your computer
  • Reloads the ~/.bash_profile file

After running this command, you should be able to execute the pip command without any issues.

Top comments (0)