Author's Picture
Author: Joel Gray Published: 18 October 2023 Read Time: ~2 minutes

How to Add Python Pip to Path

Are you sick of adding “python -m” to the beginning of your pip install commands?

Or maybe you’ve reinstalled python and realise that now you have to write “python -m pip install package” instead of just “pip install package”?

This short and simple blog will show you how to add pip to your system’s environment path, which means it will know how to find pip without prefixing it with “python -m”.


For macOS and Linux:

1. Locate pip Installation:

• Run the following command in your terminal to find where pip is installed:

python -m site --user-base

• Note the path returned, e.g., /home/username/.local.

2. Modify the PATH Environment Variable for this session:

• Append /bin to the path obtained, e.g., /home/username/.local/bin.

• For a temporary modification, run:

export PATH="$PATH:/home/username/.local/bin"

3. Modify the PATH Environment Variable permanently:

• For a permanent modification, add the above line to your ~/.bashrc (for Linux) or ~/.bash_profile (for macOS) file:

echo 'export PATH="$PATH:/home/username/.local/bin"' >> ~/.bashrc
source ~/.bashrc

4. Verify the Modification:

• Open a new terminal window and run:

pip --version

For Windows:

1. Locate pip Installation:

• Run the following command in your Command Prompt to find where pip is installed:

py -m site --user-site

• Note the path returned, e.g., C:\Users\Username\AppData\Roaming\Python\Python39\site-packages.

2. Modify the PATH Environment Variable:

• Navigate to the Scripts directory which is a sibling to the site-packages directory, e.g., C:\Users\Username\AppData\Roaming\Python\Python39\Scripts.

• Copy this path.

3. Add the Path to the Environment Variables:

• Right-click on ‘This PC’ or ‘My Computer’ on your desktop or in File Explorer, and select ‘Properties’.

• Click on ‘Advanced system settings’.

• Click on ‘Environment Variables’.

• Under ‘System variables’, scroll down and select the ‘Path’ variable, then click on ‘Edit’.

• Click on ‘New’, and paste the path copied earlier.

• Click ‘OK’ to close each window.

4. Verify the Modification:

• Open a new Command Prompt window and run:

pip --version