Python pip installation on Mac is not working

拜拜、爱过 提交于 2021-02-17 06:26:31

问题


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:


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.




回答2:


Try this

sudo easy_install pip  

Then

pip install beautifulsoup4

If it doesn't work try this:

python -m pip install beautifulsoup4



回答3:


Try below

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



回答4:


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



来源:https://stackoverflow.com/questions/63538152/python-pip-installation-on-mac-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!