如何在 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
How to install pip for Python 3 on Mac OS X?
提问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。我可以像以前那样做,即:
- Download pyserial from pypi
- untar pyserial.tgz
- cd pyserial
python3 setup.py install
- 从pypi下载pyserial
- 解压pyserial.tgz
- cd pyserial
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.
这给了我python3并pip3在我的道路上。
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
回答by Liyali
回答by northtree
brew install python3create alias in your shell profile
- eg.
alias pip3="python3 -m pip"in my.zshrc
- eg.
brew install python3在您的 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 自动安装:
brew install python3pip3 --version
brew install python3pip3 --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。pip和pip3。因此,要升级pip以python 3执行以下操作:
~$ sudo pip3 install --upgrade pip

