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

OS X(Mavericks)已安装Python 2.7库存。但是我用3.3来做我自己的所有Python个人资料。我刚刚冲洗了3.3.2安装并安装了新的3.3.3。所以我需要pyserial再次安装。我可以按照以前做过的方式来做,即:

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

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

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 pyserial again. I can do it the way I’ve done it before, which is:

  1. Download pyserial from pypi
  2. untar 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.


回答 0

更新:Python3.4不再需要此功能。它会在库存安装中安装pip3。

我最终在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

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

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

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

# use pip to install
pip install pyserial

要么:

# Don't want it?
pip uninstall pyserial

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

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

# 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:

# use pip to install
pip install pyserial

or:

# Don't want it?
pip uninstall pyserial

回答 1

我必须自己经历这个过程,并选择一种从长远来看更好的方法。

我安装了自制软件

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

然后:

brew doctor

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

然后:

brew install python3

这给了我,python3并且走pip3了我的路。

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

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.

then:

brew install python3

This gave me python3 and pip3 in my path.

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

回答 2

在Mac上安装Python3

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

使用pip3安装模块

1. pip3 install ipython
2. python3 -m IPython

:)

Install Python3 on mac

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

Use pip3 to install modules

1. pip3 install ipython
2. python3 -m IPython

:)


回答 3

另外:当您使用python3安装请求时,命令为:

pip3 install requests

pip install requests

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

pip3 install requests

not

pip install requests

回答 4

  1. brew install python3
  2. 在您的外壳配置文件中创建别名

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

➜〜pip3-版本

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

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

    • eg. alias pip3="python3 -m pip" in my .zshrc

➜ ~ pip3 –version

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


回答 5

这是我的简单解决方案:

如果您的系统中同时安装了python2和python3,则默认情况下pip升级将指向python2。因此,我们必须指定python(python3)的版本并使用以下命令:

python3 -m pip install --upgrade pip

此命令将卸载以前安装的pip并安装新版本-升级pip。

这将节省内存并使系统混乱。

图像-在MacOS上如何在Python3中升级pip

Here is my simple solution:

If you have python2 and python3 both installed in your system, the pip upgrade will point to python2 by default. Hence, we must specify the version of python(python3) and use the below command:

python3 -m pip install --upgrade pip

This command will uninstall the previously installed pip and install the new version- upgrading your pip.

This will save memory and declutter your system.

Image – How the upgrading of pip in Python3 works on MacOS


回答 6

要使用Python EasyInstall(我想您要使用它)非常简单!

sudo easy_install pip

因此,然后使用pip安装Pyserial,您可以执行以下操作:

pip install pyserial

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

sudo easy_install pip

so then with pip to install Pyserial you would do:

pip install pyserial

回答 7

另外,值得一提的是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)

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

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

回答 8

Mac OS X Mojave python代表的2.7版本,Python和python3为版本3.同样是Pythonpippip3。所以,要升级pippython 3做到这一点:

~$ sudo pip3 install --upgrade pip

On Mac OS X Mojave python stands for python of version 2.7 and python3 for python of version 3. The same is pip and pip3. So, to upgrade pip for python 3 do this:

~$ sudo pip3 install --upgrade pip

回答 9

在MacOS 10.12上

下载点数:pip asget-pip.py

下载python3:python3

  1. 安装python3
  2. 打开终端: python3 get-pip.py
  3. pip3 可用

On MacOS 10.12

download pip: pip as get-pip.py

download python3: python3

  1. install python3
  2. open terminal: python3 get-pip.py
  3. pip3 is available

回答 10

pip 使用brew通过python2自动安装:

  1. brew install python3
  2. pip3 --version

pip is installed automatically with python2 using brew:

  1. brew install python3
  2. pip3 --version

回答 11

如果您的Mac上未安装pip,则只需在终端上运行以下命令即可。

sudo easy_install pip

在此处下载python 3: python3

完成这两个步骤后,请确保运行以下命令以验证是否已成功安装它们。

python3 --version
pip3 --version

simply run following on terminal if you don’t have pip installed on your mac.

sudo easy_install pip

download python 3 here: python3

once you’re done with these 2 steps, make sure to run the following to verify whether you’ve installed them successfully.

python3 --version
pip3 --version

回答 12

对于全新的Mac,您需要执行以下步骤:-

  1. 确保已安装 Xcode
  2. sudo easy_install pip
  3. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  4. brew doctor
  5. brew doctor
  6. brew install python3

完成后,只需python3在终端上键入,就会看到安装了python 3。

For a fresh new Mac, you need to follow below steps:-

  1. Make sure you have installed Xcode
  2. sudo easy_install pip
  3. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  4. brew doctor
  5. brew doctor
  6. brew install python3

And you are done, just type python3 on terminal and you will see python 3 installed.


回答 13

我在python3和pip3中遇到了同样的问题。决策:使用链接和其他东西解决所有冲突

brew doctor

之后

brew reinstall python3

I had the same problem with python3 and pip3. Decision: solving all conflicts with links and other stuff when do

brew doctor

After that

brew reinstall python3

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。