Mac 上的 Python pip 安装不起作用 [英] Python pip installation on Mac is not working

查看:132
本文介绍了Mac 上的 Python pip 安装不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台 Macbook Air,想安装 pip.我有更新的python版本.我按照所有说明进行操作,但无法安装任何软件包.

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.

我已经研究了 1 个多小时,看了很多文章和问题,但我无法弄清楚.

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

当我尝试安装 pip,然后安装一个名为 beautifulsoup 的包时,这是我终端上显示的内容:

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.

推荐答案

看最后的警告,说这些脚本不在 PATH 中.打开 Finder,将列出的文件复制到以下目录:/usr/local/bin/

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/

转到/Users/arnau/Library/Python/2.7/bin.将列出的文件复制到/usr/local/bin/中,以便命令行可以识别您的命令 pip.

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.

如果您不想这样做(我不建议这样做),您现在可以简单地使用其他答案,其中说使用 python -m pip,它指示命令-line 到这些文件的当前目录,/Users/arnau/Library/Python/2.7/bin.但是,您将来这样做可能会遇到问题,因此我建议了上述答案.

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.

我还希望您不会在每次必须安装软件包时输入额外的 2 个关键字.

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

这篇关于Mac 上的 Python pip 安装不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆