[英]How can I install Python's pip3 on my Mac?
I'm trying to install pip3, but I'm not having any luck.我正在尝试安装 pip3,但我没有任何运气。 Also, I tried
sudo install
and it did not work.另外,我试过
sudo install
但它没有用。 How could I install pip3 on my Mac?如何在我的 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')
According to the official Homebrew page :根据官方 Homebrew 页面:
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).
2018 年 3 月 1 日,python 公式将升级到 Python 3.x,并且将添加 python@2 公式以安装 Python 2.7(尽管这将仅用于桶,因此默认情况下 python 和 python2 都不会添加到 PATH 中手动 brew 链接 --force)。 We will maintain python2, python3 and python@3 aliases.
我们将维护 python2、python3 和 python@3 别名。
So to install Python 3, run the following command:因此,要安装 Python 3,请运行以下命令:
brew install python3
Then, the pip
or pip3
is installed automatically, and you can install any package by pip install <package>
.然后,
pip
或pip3
会自动安装,您可以通过pip install <package>
安装任何包。
brew install python3
but also brew postinstall python3
brew install python3
还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.请注意,您应该检查控制台,因为它可能
pip3
您带来错误,在这种情况下,未安装pip3
。
I solved the same problem with these commands:我用这些命令解决了同样的问题:
curl -O https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
Python 3 was working successfully, but without pip3. Python 3 运行成功,但没有 pip3。 I tried advice from Stack Overflow, Quora and others (numerous installs and uninstalls).
我尝试了 Stack Overflow、Quora 和其他人的建议(多次安装和卸载)。
Python 3 was always fine, but without pip3. Python 3 一直很好,但没有 pip3。 Finally I downloaded Python3 from: https://www.python.org/downloads/
最后我从以下位置下载了 Python3: https ://www.python.org/downloads/
By simple mouse clicks and everything (Python 3 + pip3), it is working fine now.通过简单的鼠标点击和一切(Python 3 + pip3),它现在工作正常。
Similar to Oksana but add python3类似于 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
Seem now work for pip3 under mac os x 10.13.3 Xcode 9.2似乎现在适用于 mac os x 10.13.3 Xcode 9.2 下的 pip3
To install or upgrade pip, download get-pip.py from the official site .要安装或升级 pip,请从官方站点下载get-pip.py 。 Then run the following command:
然后运行以下命令:
sudo python get-pip.py
and it will install pip
for your python version which runs the script.它将为您运行脚本的 python 版本安装
pip
。
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:我运行了下面,其中
<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 also encountered the same problem but brew install python3
does not work properly to install pip3
.我也遇到了同样的问题,但是
brew install python3
无法正常安装pip3
。
brre will throw the warning The post-install step did not complete successfully
. brre 会抛出警告
The post-install step did not complete successfully
。
It has to do with homebrew does not have permission to /usr/local
它与自制软件没有权限有关
/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:将
/usr/local
的权限授予 homebrew,以便它可以访问它们:
sudo chown -R $(whoami) $(brew --prefix)/*
Now ostinstall python3现在 ostinstall python3
brew postinstall python3
This will give you a successful installation这将使您安装成功
After upgrading to macOS v10.15 (Catalina), and upgrading all my vEnv modules, pip3 stopped working (gave error: "TypeError: 'module' object is not callable").升级到macOS v10.15 (Catalina) 并升级我所有的 vEnv 模块后,pip3 停止工作(给出错误:“TypeError: 'module' object is not callable”)。
I found question 58386953 which led to here and solution.我发现问题 58386953导致这里和解决方案。
sudo python3 -m pip uninstall pip
(this is necessary, but it did not fix problem, because it removed the base Python pip, but it didn't touch my vEnv pip) sudo python3 -m pip uninstall pip
(这是必要的,但它没有解决问题,因为它删除了基本的 Python pip,但它没有触及我的 vEnv pip)sudo easy_install pip
(reinstalling pip in base Python, not in vEnv) sudo easy_install pip
(在基础 Python 中重新安装 pip,而不是在 vEnv 中)vEnv/bin
and type "source activate" to get into vEnv vEnv/bin
并输入“source activate”进入 vEnvrm pip pip3 pip3.6
(it seems to be the only way to get rid of the bogus pip's in vEnv) rm pip pip3 pip3.6
(这似乎是摆脱 vEnv 中虚假 pip 的唯一方法) Installing Pip3安装 Pip3
Now simply do pip3 install <package>
现在只需执行
pip3 install <package>
If you're using Python 3, just execute python3 get-pip.py
.如果您使用的是 Python 3,只需执行
python3 get-pip.py
。 It is just a simple command.这只是一个简单的命令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.