I need to get pip3
running on my Mac terminal for a project. I have python3
installed, and I can run it, but when I try to run pip3 freeze
, it says my command is not found.
I thought it would be automatically installed when I installed Python3. I tried to sudo install it, but it still didn't do anything. 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 . 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
. This should get pip3
installed on your machine.
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
.
This is the location of python3
if you installed it via MacPorts. If you installed it with HomeBrew, then it would be /usr/local/Cellar/python/3.7.0/bin/pip3
(again, version might vary).
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:
$ /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 pip3
As a last resort, the slow find
can also be useful:
$ 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
):
$ 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:
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. ( more here )
This solution will allow you to use pip
by python3 -m pip
, but in order to use pip3
directly you can:
Install it via Homebrew
:
brew install pip3
Install it with get-pip.py
:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python get-pip.py
You could try brew install pip3
. Or check where pip
is installed, that might point to Python 3's version.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.