问题:如何在Mac上安装pip3?

我正在尝试安装pip3,但没有任何运气。此外,我尝试了sudo install,但没有成功。如何在Mac上安装pip3?

sudo easy_install pip3
Password:
Searching for pip3
Reading https://pypi.python.org/simple/pip3/
Couldn't find index page for 'pip3' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/

No local packages or download links found for pip3
error: Could not find suitable distribution for Requirement.parse('pip3')

I’m trying to install pip3, but I’m not having any luck. Also, I tried sudo install and it did not work. How could I install pip3 on my Mac?

sudo easy_install pip3
Password:
Searching for pip3
Reading https://pypi.python.org/simple/pip3/
Couldn't find index page for 'pip3' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/

No local packages or download links found for pip3
error: Could not find suitable distribution for Requirement.parse('pip3')

回答 0

更新-1.5之后的自制版本

根据官方的Homebrew页面

在2018年3月1日,python公式将升级到Python 3.x,并且将添加python @ 2公式以安装Python 2.7(尽管这仅是小桶,因此默认情况下python和python2都不会添加到PATH中,而无需手动冲泡链接–force)。我们将维护python2,python3和python @ 3别名。

因此,要安装Python 3,请运行以下命令:

brew install python3

然后,pippip3会自动安装,您可以通过安装任何软件包pip install <package>


旧版本的Homebrew

不仅brew install python3而且brew postinstall python3

因此,您必须运行:

brew install python3
brew postinstall python3

请注意,您应该检查控制台,因为它可能会导致您出错,并且在这种情况下,pip3不会安装。

UPDATED – Homebrew version after 1.5

According to the official Homebrew page:

On 1st March 2018 the python formula will be upgraded to Python 3.x and a python@2 formula will be added for installing Python 2.7 (although this will be keg-only so neither python nor python2 will be added to the PATH by default without a manual brew link –force). We will maintain python2, python3 and python@3 aliases.

So to install Python 3, run the following command:

brew install python3

Then, the pip or pip3 is installed automatically, and you can install any package by pip install <package>.


The older version of Homebrew

Not only brew install python3 but also brew postinstall python3

So you must run:

brew install python3
brew postinstall python3

Note that you should check the console, as it might get you errors and in that case, the pip3 is NOT installed.


回答 1

你可以用 自制的

然后运行:

brew install python3

You could use home-brew

Then just run:

brew install python3

回答 2

我用以下命令解决了相同的问题:

curl -O https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py

I solved the same problem with these commands:

curl -O https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py

回答 3

对我来说brew postinstall python3没用。在GitHub自制问题页面上找到了此解决方案:

$ brew rm python 
$ rm -rf /usr/local/opt/python
$ brew cleanup 
$ brew install python3

For me brew postinstall python3 didn’t work. Found this solution on GitHub homebrew issues page:

$ brew rm python 
$ rm -rf /usr/local/opt/python
$ brew cleanup 
$ brew install python3

回答 4

Python3成功运行,但没有pip3。尝试了许多来自stackoverflow,quora等的建议。(大量安装和卸载)

Python3总是很好,但是没有pip3。最后,我从以下网址下载了Python3:https://www.python.org/downloads/

只需单击鼠标,一切(Python3 + pip3)现在都可以正常工作。

Python3 was working successfully but without pip3. Tried many advises from stackoverflow, quora and others. (numerous installs and uninstalls)

Python3 was always fine but without pip3. Finally I downloaded Python3 from: https://www.python.org/downloads/

By simple mouse clicks and everything (Python3 + pip3) is working fine now.


回答 5

要安装或升级pip,官方网站下载get-pip.py。然后运行以下命令:

sudo python get-pip.py 

它将安装pip为您的运行脚本的python版本。

To install or upgrade pip, download get-pip.py from the official site. Then run the following command:

sudo python get-pip.py 

and it will install pip for your python version which runs the script.


回答 6

类似于Oksana,但添加了python3

$ brew rm python 
$ brew rm python3 
$ rm -rf /usr/local/opt/python
$ rm -rf /usr/local/opt/python3
$ brew prune 
$ brew install python3
$ brew postinstall python3

似乎现在适用于Mac OS X 10.13.3 Xcode 9.2的pip3

Similar to Oksana but add python3

$ brew rm python 
$ brew rm python3 
$ rm -rf /usr/local/opt/python
$ rm -rf /usr/local/opt/python3
$ brew prune 
$ brew install python3
$ brew postinstall python3

Seem now work for pip3 under mac os x 10.13.3 Xcode 9.2


回答 7

我在目录中运行以下<user>:<group><user>:<group>其他文件匹配的其他文件/usr/local/lib/python3.7/site-packages/

sudo chown -R <user>:<group> /usr/local/lib/python3.7/site-packages/pip*
brew postinstall python3

I ran the below where <user>:<group> matched the other <user>:<group> for other files in the /usr/local/lib/python3.7/site-packages/ directory:

sudo chown -R <user>:<group> /usr/local/lib/python3.7/site-packages/pip*
brew postinstall python3

回答 8

我也遇到了同样的问题,但brew install python3无法正常安装pip3

布雷会发出警告The post-install step did not complete successfully

它与自制有关,没有许可 /usr/local

创建目录(如果不存在)

sudo mkdir lib 
sudo mkdir Frameworks

在内部/usr/local授予自制权限,以便可以访问它们:

sudo chown -R $(whoami) $(brew --prefix)/*

现在ostinstall python3

brew postinstall python3

这将为您成功安装

I also encountered the same problem but brew install python3 does not work properly to install pip3.

brre will throw the warning The post-install step did not complete successfully.

It has to do with homebrew does not have permission to /usr/local

Create the directory if not exist

sudo mkdir lib 
sudo mkdir Frameworks

Give the permissions inside /usr/local to homebrew so it can access them:

sudo chown -R $(whoami) $(brew --prefix)/*

Now ostinstall python3

brew postinstall python3

This will give you a successful installation


回答 9

升级到Mac OS Catalina之后,并升级了所有vEnv模块,pip3停止工作(产生错误:“ TypeError:’模块’对象不可调用”)。

找到问题58386953,导致这里出现问题并解决。

  1. 从vEnv退出(我启动了新的Shell)
  2. sudo python3 -m pip uninstall pip (这是必要的,但没有解决问题,因为它删除了基本的Python点子,但没有碰到我的vEnv点子)
  3. sudo easy_install pip (在基本Python中而不是vEnv中重新安装pip)
  4. cd到您的计算机上,vEnv/bin然后键入“ source activate”进入vEnv
  5. rm pip pip3 pip3.6 (似乎是摆脱vEnv中虚假点的唯一方法)
  6. 现在pip已从vEnv中消失,我们可以在基本Python中使用一个(我无法在删除后将pip成功安装到vEnv中)

After upgrading to Mac OS Catalina, and upgrading all my vEnv modules, pip3 stopped working (gave error: “TypeError: ‘module’ object is not callable”).

Found question 58386953 which led to here and solution.

  1. Exit from vEnv (I started fresh shell)
  2. sudo python3 -m pip uninstall pip (this is necessary, but did not fix problem, because it removed the base Python pip, but didn’t touch my vEnv pip)
  3. sudo easy_install pip (reinstalling pip in base Python, not in vEnv)
  4. cd to your vEnv/bin and type “source activate” to get into vEnv
  5. rm pip pip3 pip3.6 (seems to be the only way to get rid of the bogus pip’s in vEnv)
  6. Now pip is gone from vEnv, and we can use the one in the base Python (I wasn’t able to successfully install pip into vEnv after deleting)

回答 10

如果您使用的是python3,请执行python3 get-pip.py。只是一个简单的命令。

if you’re using python3 just execute python3 get-pip.py . Just a simple command.


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