如何在 Mac OS X 上为 Python 3 安装 pip?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20082935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 19:29:08  来源:igfitidea点击:

How to install pip for Python 3 on Mac OS X?

pythonmacospython-3.xpippython-3.3

提问by Travis Griggs

OS X (Mavericks) has Python 2.7 stock installed. But I do all my own personal Python stuff with 3.3. I just flushed my 3.3.2 install and installed the new 3.3.3. So I need to install pyserialagain. I can do it the way I've done it before, which is:

OS X (Mavericks) 安装了 Python 2.7 stock。但是我用 3.3 做所有我自己的个人 Python 东西。我刚刚刷新了我的 3.3.2 安装并安装了新的 3.3.3。所以我需要重新安装pyserial。我可以像以前那样做,即:

  1. Download pyserial from pypi
  2. untar pyserial.tgz
  3. cd pyserial
  4. python3 setup.py install
  1. 从pypi下载pyserial
  2. 解压pyserial.tgz
  3. cd pyserial
  4. python3 setup.py install

But I'd like to do like the cool kids do, and just do something like pip3 install pyserial. But it's not clear how I get to that point. And just that point. Not interested (unless I have to be) in virtualenv yet.

但我想像酷孩子一样做,只是做类似的事情pip3 install pyserial。但目前尚不清楚我是如何做到这一点的。而就在这一点上。对 virtualenv 不感兴趣(除非我必须)。

采纳答案by Travis Griggs

UPDATE: This is no longer necessary with Python3.4. It installs pip3 as part of the stock install.

更新:Python3.4 不再需要这样做。它安装 pip3 作为库存安装的一部分。

I ended up posting this same question on the python mailing list, and got the following answer:

我最终在 python 邮件列表上发布了同样的问题,并得到了以下答案:

# download and install setuptools
curl -O https://bootstrap.pypa.io/ez_setup.py
python3 ez_setup.py
# download and install pip
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py

Which solved my question perfectly. After adding the following for my own:

这完美地解决了我的问题。在为我自己添加以下内容后:

cd /usr/local/bin
ln -s ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/pip pip

So that I could run pip directly, I was able to:

为了可以直接运行 pip,我能够:

# use pip to install
pip install pyserial

or:

或者:

# Don't want it?
pip uninstall pyserial

回答by l'L'l

To use Python EasyInstall (which is what I think you're wanting to use), is super easy!

使用 Python EasyInstall(这是我认为您想要使用的),非常简单!

sudo easy_install pip

so then with pip to install Pyserial you would do:

所以然后用 pip 安装 Pyserial 你会这样做:

pip install pyserial

回答by Pieter Breed

I had to go through this process myself and chose a different way that I think is better in the long run.

我必须自己经历这个过程,并选择了一种我认为从长远来看更好的不同方式。

I installed homebrew

我安装了自制软件

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

then:

然后:

brew doctor

The last step gives you some warnings and errors that you have to resolve. One of those will be to download and install the Mac OS X command-line tools.

最后一步为您提供了一些必须解决的警告和错误。其中之一是下载并安装Mac OS X 命令行工具

then:

然后:

brew install python3

This gave me python3and pip3in my path.

这给了我python3pip3在我的道路上。

pieter$ which pip3 python3
/usr/local/bin/pip3
/usr/local/bin/python3

回答by Alan Dong

Install Python3on mac

在 Mac 上安装Python3

1. brew install python3
2. curl https://bootstrap.pypa.io/get-pip.py | python3
3. python3

Use pip3to install modules

使用pip3安装模块

1. pip3 install ipython
2. python3 -m IPython

:)

:)

回答by steven

Plus: when you install requests with python3, the command is:

另外:当你用 python3 安装请求时,命令是:

pip3 install requests

not

不是

pip install requests

回答by Lincoln

On MacOS 10.12

在 MacOS 10.12 上

download pip: pipas get-pip.py

下载 pip: pipasget-pip.py

download python3: python3

下载python3:python3

  1. install python3
  2. open terminal: python3 get-pip.py
  3. pip3is available
  1. 安装python3
  2. 打开终端: python3 get-pip.py
  3. pip3可用

回答by Liyali

Also, it's worth to mention that Max OSX/macOS users can just use Homebrewto install pip3.

此外,值得一提的是,Max OSX/macOS 用户只需使用Homebrew即可安装 pip3。

$> brew update
$> brew install python3
$> pip3 --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

回答by northtree

  1. brew install python3
  2. create alias in your shell profile

    • eg. alias pip3="python3 -m pip"in my .zshrc
  1. brew install python3
  2. 在您的 shell 配置文件中创建别名

    • 例如。alias pip3="python3 -m pip"在我的.zshrc

? ~ pip3 --version

? ~ pip3 --version

pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

来自 /usr/local/lib/python3.6/site-packages (python 3.6) 的 pip 9.0.1

回答by Darmen Amanbayev

pipis installed automatically with python2 using brew:

pip使用 brew 与 python2 自动安装:

  1. brew install python3
  2. pip3 --version
  1. brew install python3
  2. pip3 --version

回答by Denis Kutlubaev

On Mac OS X Mojavepythonstands for python of version 2.7 and python3for python of version 3. The same is pipand pip3. So, to upgrade pipfor python 3do this:

OnMac OS X Mojavepython代表 2.7 版python3的 python 和 3 版的 python。pippip3。因此,要升级pippython 3执行以下操作:

~$ sudo pip3 install --upgrade pip