How to Fix: pip command not found error in Ubuntu

2 min


A quick and simple guide to fix pip command not found in Ubuntu and other Linux distributions.

You might have encountered the “pip command not found” error while installing any Python package or module. This error occurs when the system cannot locate the pip package manager used to install and manage Python packages.

The pip package manager is not installed by default on Ubuntu & other Linux distros. It’s worth noting that Python is installed by default in all Linux distributions. But not the pip package manager. So, when you try to run a pip command, the system cannot locate the pip executable file, resulting in the “pip command not found” error.

Command pip not found
Command pip not found

Here’s how to fix it.

Solution 1: Installing pip on Ubuntu and other distros

  • The simplest way to fix the pip command not found error is to install the pip package manager on Ubuntu. You can install pip by running the following command in the terminal:
sudo apt install python3-pip
  • This command will install the pip package manager for Python 3 on your Ubuntu system. Once the installation is complete, you can run pip commands without the error.
  • For Arch Linux, the package name is different i.e. python-pip. Install it using the below command. It’s available in Arch Extra repo.
sudo pacman -S python-pip
  • For Fedora, RHEL-based distros use:
sudo dnf install python3-pip

Solution 2: Updating the PATH environment variable

If you have already installed pip on your Ubuntu system but are still encountering the “pip command not found” error, you may need to update the PATH environment variable.

To update the PATH environment variable, you need to add the directory containing the pip executable file to the list of directories in the PATH variable. One of the way of update the PATH is using the below command.

export PATH=$PATH:/usr/local/bin

This command adds the directory /usr/local/bin to the list of directories in the PATH variable. This is the directory where pip installs the pip executable file.

Solution 3: Creating a symbolic link

If you have installed pip in some other custom directory, then you can create a symbolic link to your custom pip executable path to /usr/local/bin/pip. Then you can easily run the command from the terminal without any error.

Here’s an example of the command. Replace /custom/path/to/pip with your directory path.

sudo ln -s /custom/path/to/pip /usr/local/bin/pip

Solution 4: Upgrading pip

If you have an outdated version of pip installed on your system, you may encounter the “pip command not found” error. To fix this, you can upgrade pip to the latest version using the following command:

python -m pip install --upgrade pip

Conclusion

The “pip command not found” error can be a problem while setting up your system for Python development. Fortunately, there are several solutions available to fix this error as explained above. I hope you are able to resolve this error using any of the steps outlined above.


Arindam

Creator and author of debugpoint.com. Connect with me via Telegram, 𝕏 (Twitter), or send us an email.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments