61

I tried to install pip in python $ python get-pip.py through terminal but had this warning in Terminal.

Python3.8
MacOS Catalina

Please help :( . I have been trying to search for answers for days

WARNING: The scripts pip, pip3 and pip3.8 are installed in '/Library/Frameworks/Python.framework/Versions/3.8/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
3
  • 1
    Why are you trying to install pip? It is normally included in every python installation. normally if you want to install a package e.g. numpy you can directly call python -m pip install numpy. Commented Apr 4, 2020 at 9:28
  • 12
    Add export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.8/bin" to the .bash_profile file in your home dir. From terminal: $ echo -e 'export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.8/bin"' >> $HOME/.bash_profile Commented Apr 4, 2020 at 9:31
  • 1
    Thanks it solved my problem :) Commented Apr 5, 2020 at 11:44

8 Answers 8

34

You are getting this error because of the absence of the location that pip is installed from your PATH.

You need add:

export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.8/bin"

to the end of your .bash_profile, like @hoefling commented.

Sign up to request clarification or add additional context in comments.

3 Comments

how to do this for Ubuntu
@uber add that line to the end of .bashrc file in /home/user/.bashrc file. You can use editor of your choice. Run gedit /home/user/.bachrc in your terminal and add that line at the end. Note: in the earlier command, replace user with your username
I executed "export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.8/bin"" in terminal, and then something bad happened, "python --version" get "command not found"
16

As of March 2022, under macOS Monterey 12.2.1, I had to use a different PATH change to reach pip:

export PATH="$PATH:/Users/<username>/Library/Python/3.8/bin"

Notes:

  1. My python installation is not at /Library/ but rather at ~/Library/, possibly because it arrived via brew - or that Monterey uses a different location.
  2. $PATH does not seem to tolerate ~/ - so one rather has to use /Users/<username>/... in at least this case.
  3. I think it's better to append rather than to prepend the updated path, because by default one might want/expect the system's main paths (/usr/bin etc.) to take precedence. On the other hand, installing e.g. python to those main paths will also take precedence over any python setup that depends on the updated path and could therefore damage it. Choose your poison.
  4. This answer is not the same as the currently-top answer because (i) the required path is different for me and (ii) the OS version is different.

3 Comments

In my Monterey, pip was installed to the/Library/Frameworks/Python.framework/.... My pip was installed through python pip-get ready. Therefore, I guess get-ready installed pip to the default dir of python.org (/Library/Framwork...).
This comment was the winner for me. Thanks so much!
after saving - be sure to restart with the command: source ~/.zshrc
9

I am using Ubuntu and the following worked for me:

nano ~/.bashrc # to open the .bashrc file

Then Ctrl+End #to reach the end of the file.

On a new line, put the following line:

export PATH=$PATH:/home/$USER/.local/bin

Save changes and finally logout and login again to make this work

Comments

7

If you are on a Raspberry Pi (Raspbian OS) then do the following:

nano /home/pi/.profile

At the end of the file add:

# set PATH to pip
PATH="$HOME/pi/.local/bin:$PATH"

Ctrl+X, Y, Enter <-- to save changes on the .profile file

Then reboot your Raspberry Pi to apply changes.

You can check now with pip --version

Comments

3

This worked for me on mac:

export PATH="$PATH:/Users/<usernane>/Library/Python/<version>/bin" 

Comments

1

That is not so easy to do correctly (portable and future proof) but here is something that should work decently:

SCRIPTS_DIR=$(python3 -c 'import os,sysconfig;print(sysconfig.get_path("scripts",f"{os.name}_user"))')
if [[ ":$PATH:" != *":$SCRIPTS_DIR:"* ]]; then
    export PATH=$SCRIPTS_DIR:$PATH
    # that is for github actions users:
    echo "$SCRIPTS_DIR" >> $GITHUB_PATH
    echo "Added $SCRIPTS_DIR to PATH to avoid further issues."
fi

Comments

0

You need to add to your .bash_profile or .zshrc in your system root directory:

export PATH=/Library/Frameworks/Python.framework/Versions/3.9/bin:$PATH

2 Comments

Welcome to Stack Overflow. Please read How to Answer. How is this different from the existing answer with 10 upvotes?
If you are on a Raspberry Pi (Raspbian OS) then do the following: <code> nano /home/pi/.profile </code> At the end of the file add: <code> # set PATH to pip PATH="$HOME/pi/.local/bin:$PATH" </code>
0

I updated my .zshrc export PATH="${PATH}:/Users/adongu/Library/Python/3.7/bin to export PATH="${PATH}:/Users/adongu/Library/Python/3.9/bin

Instead of "${PATH}:/Users/adongu/Library/Python/3.9/bin tried "PATH="${PATH}:/Users/adongu/Library/Python/3.9/bin" and that worked.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.