Whether the correct command for Python 3 is pip
or pip3
or (say) gaschplutzga
depends on a number of factors.
If you only have Python 3, and you have a command named pip
, that's probably safe to use. Going forward, this will be the simple, obvious, safe answer in more and more places.
If you have both, and there is a command called pip3
installed on your system, probably that's the correct one to use.
More generally, you can go through your PATH
and look for commands with suitable names. On Unix-like systems with a POSIX-compatible shell, try the commands command -V pip3
and command -V pip
. (On Windows systems, maybe try where pip3
and where pip
, or pray to whatever dark deity informed your choice of operating system.)
If you receive output like
/opt/random/nonstandard/whoa/pip
/usr/local/bin/pip
/usr/bin/pip
you can try each of these in turn with the full path and adding the --version
option to have them identify themselves. When you specify the full path, you are bypassing the system's PATH
mechanism entirely. For example,
/opt/random/nonstandard/whoa/pip --version
might identify itself as belonging to Python version 3.2.1. If that's the one you want, and it's at the top of your PATH
, you can simply rely on the PATH
to give you this version when you type just pip
. If not, perhaps you can shuffle your PATH
(but understand that this changes the resolution order for all commands in the directory whose position you change) or create a simple alias or wrapper which bypasses the PATH
for this particular command in your personal account. On Unix-like systems with a POSIX-compatible shell, this might look like
alias pip=/opt/random/nonstandard/whoa/pip
(to persist this across sessions, you'd add this to your .profile
or similar - for Bash, try .bash_profile
if it exists; for Zsh, try .zshrc
. The full scoop for each shell is more complicated than I can squeeze into these narrow parentheses); on Windows, you might be able to control this by setting the environment variable PY_PYTHON
, but there's a huge can of worms behind that "might".
Some sites and OSes / distros have additional wrappers or conventions which introduce additional options; if you use a specific package manager, perhaps also study its documentation. (One common example is Anaconda, though I don't believe it affects the naming or location of pip
specifically.)