8

I installed python3 from www.python.org(not thru brew). I found that I did not have pip then, only pip3. As here said https://pip.pypa.io/en/stable/installing/

pip is already installed if you are using Python 2 >=2.7.9 or Python 3 >=3.4 downloaded from python.org

So how do I get pip installed ?

Homebrew document also confirms this

Note: macOS’s system Python does not provide pip. Follow the pip documentation to install it for your system Python if you would like it.

6
  • Is there a question here? (This seems better as a blog post if the answer isn’t provided in the answer section)
    – bmike
    Commented Nov 25, 2020 at 2:21
  • In the beginning it was a question but I finally figured it out myself so I added in in update section. (all the answers didn't apply to my case) Commented Nov 25, 2020 at 3:26
  • 1
    To fit in to the Q&A nature here, you could move all the answer to the answer and edit the question so it’s short and clear. It’s encouraged to answer your own question. apple.stackexchange.com/help/self-answer
    – bmike
    Commented Nov 25, 2020 at 4:04
  • 1
    Done. To tell you the truth, I didn't get why my question got downvoted. So if it is not because you suggested I won't bother. Commented Nov 25, 2020 at 4:18
  • Looks worth a +1 to me for the post and the answer. Perhaps it’s all the critical comments on the all the answers trying to help. I wouldn’t worry, comments go away and over time useful questions tend to get some votes up.
    – bmike
    Commented Nov 25, 2020 at 5:07

6 Answers 6

6

If you had python 2.x and then installed python3, your pip will be pointing to pip3. you can verify that by typing pip --version which would be the same as pip3 --version.

On your system, you have now pip, pip2 and pip3.

If you want you can change pip to point to pip2 instead of pip3.

you can either add the alias to your ~/.bashrc

 alias pip=pip3

or add to your $PATH symlink named pip pointing to pip3 binary

0
4

MacOS comes with python version 2.7.10. This version does not include pip.

If you download and install python3 from python.org, then you will get pip3 as the command to install python modules for python3.

If you download an updated version of python 2.7 from python.org, that will come with pip. At which point, pip will install stuff for python2, and pip3 will install stuff for python3. The two installations are entirely separate.

As jmh points out, if you just want to add pip to the existing OS-bundled python 2.7, then there's an easy command to do that.

sudo easy_install pip
3

You can install pip after installing pip3 on mac by using pip3 install --upgrade pip . pip3 works fine but in some cases, like when installing jupyter pip is better.

2

You can try the following command on the terminal: sudo easy_install pip.

0
2

macOS 10.14.6 preinstalled python 2.7.10, but it doesn't come with pip. It does have pip3 for python3.

bash-3.2$ python --version
Python 2.7.10
bash-3.2$ which pip
bash-3.2$ which pip2
bash-3.2$

I just want pip to be pip3 BUT not with alias because on other mac I found they are not alias.

~ ➤ which pip
/usr/local/bin/pip
~ ➤ which pip3
/usr/local/bin/pip3
~ ➤ ls -al /usr/local/bin/pip
-rwxr-xr-x  1 qiulang  admin  235 Oct  8 17:58 /usr/local/bin/pip
~ ➤ ls -al /usr/local/bin/pip3
lrwxr-xr-x  1 qiulang  admin  33 Oct  8 17:53 /usr/local/bin/pip3 -> ../Cellar/python/3.7.2_1/bin/pip3
~ ➤ pip --version
pip 19.2.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
~ ➤ pip3 --version
pip 19.2.3 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

This SO helps as well https://stackoverflow.com/questions/17271319/how-do-i-install-pip-on-macos-or-os-x

I finally find the easy way to let pip to be pip3 is just update it

lang@localhost % sudo pip3 install --upgrade pip

But then the preinstalled pip3 will be "obsolete":

lang@localhost  % pip3 -V
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
pip 20.2.4 from /Library/Python/3.8/site-packages/pip (python 3.8)
lang@localhost % pip -V
pip 20.2.4 from /Library/Python/3.8/site-packages/pip (python 3.8)
 

This article https://techwithtech.com/python-pip-vs-pip3/ is quite good in explaining pip overall

9
  • That is a mess pip3 is not from www.python.org but from Homebrew. You need to use one or the other
    – mmmmmm
    Commented Jul 22, 2021 at 9:54
  • I updated my answer today by adding techwithtech.com/python-pip-vs-pip3. But the "real" reason I did that was I really don't see the benefit of python -m pip install vs pip install even though I know it is for the case when I install several python versions on my machine. Commented Jul 22, 2021 at 10:05
  • It also solves the issue of having to install a pip and then relating it to a python - not just the version number but also python.org or Homebrew etc. It provides less moving parts so is easier to manage. ALso if this had been done earlier your question would have been unnecessary.
    – mmmmmm
    Commented Jul 22, 2021 at 10:16
  • Can you elaborate the part "easier to manage" (maybe with an answer)? That is the part I don't see (or haven't seen). I have to be honest that I really don't appreciate the use of python -m pip. Commented Jul 22, 2021 at 10:23
  • 1
    Which says "They do exactly the same thing. In fact, the docs for distributing Python modules were just updated to suggest using python -m pip instead of the pip executable, because it's easier to tell which version of python is going to be used to actually run pip that way." ie pip choses which python to use and it is not necessary the one you want. The answer is true if you have only one python installed and is looking more about what code is executed in pythgon not how python is found
    – mmmmmm
    Commented Jul 22, 2021 at 10:37
1

If I understand correctly, you want to have pip for your installation of Python 2.7. The builtin Python 2.7 with macOS does not include pip, so you will have to install Python 2.7 as well, either by brew or from the installation packages on Python.org. This will install pip for your installation of Python 2.7 and will additionally give you the alias pip2.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .