[英]Python3 running on Mac but no Pip3?
I need to get pip3
running on my Mac terminal for a project. 我需要在Mac终端上为一个项目运行
pip3
。 I have python3
installed, and I can run it, but when I try to run pip3 freeze
, it says my command is not found. 我已经安装了
python3
,并且可以运行它,但是当我尝试运行pip3 freeze
,它说找不到我的命令。
I thought it would be automatically installed when I installed Python3. 我以为安装Python3时会自动安装它。 I tried to sudo install it, but it still didn't do anything.
我试图对它进行sudo安装,但仍然没有执行任何操作。 What can I do?
我能做什么?
Besides brew install pip3
, in case brew
is not installed on your Mac, you can install pip3
via get_pip.py
which can be found here . 除了
brew install pip3
,如果brew
没有在Mac上安装,您可以安装pip3
通过get_pip.py
可以找到这里 。 Assuming that python3
is already installed, cd
to the directory where you saved get_pip.py
and run the file with python3 get_pip.py
. 假设已经安装了
python3
,将cd
转到保存get_pip.py
的目录,然后使用python3 get_pip.py
运行该文件。 This should get pip3
installed on your machine. 这应该在您的计算机上安装了
pip3
。
On my MacBook Pro (10.13.5), which pip3
shows that it is located at /opt/local/bin/pip3
but it is a symlink to /opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3
. 在我的MacBook Pro(10.13.5)上,
which pip3
显示它位于/opt/local/bin/pip3
但它是/opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3
的符号链接/opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3
。
This is the location of python3
if you installed it via MacPorts. 如果您是通过MacPorts安装的,则这是
python3
的位置。 If you installed it with HomeBrew, then it would be /usr/local/Cellar/python/3.7.0/bin/pip3
(again, version might vary). 如果您使用HomeBrew进行安装,则它将为
/usr/local/Cellar/python/3.7.0/bin/pip3
(同样,版本可能会有所不同)。
pip3
pip3
What I would do if I were you is first find out where your pip3
actually is by either using locate
or trying to manually find it by typing (Change 3.6 to whatever version you're on.) either: 如果我是您,我会怎么做,首先要通过使用
locate
或尝试通过键入(将3.6更改为您所使用的任何版本)来手动找到pip3
实际位置:
$ /opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3 --version
or: 要么:
$ /usr/local/Cellar/python/3.7.0/bin/pip3 --version
You should see something like: 您应该看到类似以下内容:
pip 9.0.3 from /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (python 3.6)
Otherwise, use locate
: 否则,使用
locate
:
$ locate pip3
As a last resort, the slow find
can also be useful: 作为最后的选择,缓慢
find
也可能有用:
$ sudo find / -name pip3
Then, make a symbolic link to that file in a path that is in your $PATH
(again, ensure you replace the first path with the path to your actual pip3
): 然后,在
$PATH
中的路径中建立指向该文件的符号链接(同样,请确保将第一个路径替换为实际pip3
的路径):
$ sudo ln -s /opt/local/Library/Frameworks/Python.framework/Versions/3.6/bin/pip3 /opt/local/bin/pip3
Assuming you are using Python 3.4 or later in which pip
is included by default, try the following command: 假设您使用的是默认包含
pip
Python 3.4或更高版本,请尝试以下命令:
python3 -m pip freeze
When you use the -m
command-line flag, python will search sys.path
for the named module and execute its contents as the __main__
module. 当您使用
-m
命令行标志时,python将在sys.path
中搜索指定的模块,并将其内容作为__main__
模块执行。 ( more here ) ( 更多在这里 )
This solution will allow you to use pip
by python3 -m pip
, but in order to use pip3
directly you can: 此解决方案将允许您通过
python3 -m pip
使用pip
,但是要直接使用pip3
,您可以:
Install it via Homebrew
: 通过
Homebrew
安装:
brew install pip3 酿造安装pip3
Install it with get-pip.py
: 使用
get-pip.py
安装它:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python get-pip.py 卷曲https://bootstrap.pypa.io/get-pip.py -o get-pip.py python get-pip.py
You could try brew install pip3
. 您可以尝试
brew install pip3
。 Or check where pip
is installed, that might point to Python 3's version. 或检查
pip
的安装位置,这可能指向Python 3的版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.