5

I have a Macbook Air and want to install pip. I have the updated python version. I follow all the instructions but I cannot install any packages.

I have been researching for more than 1 hour and looking at many articles and questions but I cannot figure it out.

This is what is displayed on my Terminal when I try to install pip, and then install a package called beautifulsoup:

arnau@MacBook-Air-de-Arnau ~ % python --version
Python 2.7.16
arnau@MacBook-Air-de-Arnau ~ % curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1840k  100 1840k    0     0   320k      0  0:00:05  0:00:05 --:--:--  439k
arnau@MacBook-Air-de-Arnau ~ % python get-pip.py
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Collecting pip
  Using cached pip-20.2.2-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.2.2
    Uninstalling pip-20.2.2:
      Successfully uninstalled pip-20.2.2
  WARNING: The scripts pip, pip2 and pip2.7 are installed in '/Users/arnau/Library/Python/2.7/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.
  NOTE: The current PATH contains path(s) starting with `~`, which may not be expanded by all applications.
Successfully installed pip-20.2.2
arnau@MacBook-Air-de-Arnau ~ % pip install beautifulsoup4
zsh: command not found: pip
arnau@MacBook-Air-de-Arnau ~ % 

I don't understand what is happening or what I should do to solve the error.

1

7 Answers 7

7

Look at the final warning, which says that these scripts are not in PATH. Open Finder, and copy the listed files into the following directory: /usr/local/bin/

Go to /Users/arnau/Library/Python/2.7/bin. Duplicate the files listed into /usr/local/bin/ so that the command-line can recognize your command, pip.

If you don’t want to do this (which I don’t suggest), you can simply use the other answers for now which say to use python -m pip, which directs the command-line to the current directory of these files, /Users/arnau/Library/Python/2.7/bin. You may, however run into problems in the future doing this, so I suggested my above answer.

I also expect that you won’t want to type an additional 2 keywords every time you have to install a package.

3
  • I did it and it works. Thanks, I didn't understand what "PATH" means. python -m pip also works.
    – Arnold Gee
    Aug 22, 2020 at 16:03
  • 1
    for me, running 'python3 -m pip' is what worked
    – pir800
    Jun 6, 2021 at 20:30
  • I looked for a day and a half for this answer. I think I screwed something up becuase I was downloading into my icloud drive? Do you know if that can impact development?
    – Spence_p
    Dec 29, 2021 at 18:44
5

Try below

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
3

Try this

sudo easy_install pip  

Then

pip install beautifulsoup4

If it doesn't work try this:

python -m pip install beautifulsoup4
3
  • it works! But why do I have to write python -m before pip install beautifulsoup4? What does the -m mean?
    – Arnold Gee
    Aug 22, 2020 at 15:57
  • 2
    '''pip install beautifulsoup4''' doesn't work because pip is not configured properly. python -m does many things. Check it here stackoverflow.com/questions/7610001/…
    – Baban Gain
    Aug 22, 2020 at 16:02
  • 1
    Thanks for the link. I will sure read it whole. I am new to python (3 days in) and still have a lot to learn.
    – Arnold Gee
    Aug 22, 2020 at 16:05
0

Install it form here: https://www.python.org/downloads and check "Add to PATH".. . It comes with pip installed

0

If neither of the above options work try :

sudo easy_install pip

Then :

python get-pip.py

This worked for me cause I kept getting errors

0
0

type in "install pip3" in the terminal

0

Try checking this link, and Please enter the shown command(similar to python -m ensurepip --upgrade) in the terminal. After successful complication make sure to check using the command pip3 --version in terminal to check if the installation was successful or not

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.