Mac上的Python pip安装无法正常工作 [英] Python pip installation on Mac is not working

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

问题描述

我有一个Macbook Air,想要安装点子.我有更新的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天全站免登陆