I uninstalled pip
, and I installed pip3
instead. Now, I want to use pip3
by typing pip
only. The reason is I am used to type pip
only and every guide uses the pip
command, so every time I want to copy and paste commands, I have to modify pip
to pip3
which wastes time. When I type pip
I have an error which is pip: command not found
which means pip
command is not taken. Is it possible to make pip
points to pip3
?

- 2,369
- 3
- 13
- 24
-
please consider my answer, that, I think, is proper than an alias – noraj Aug 16 '18 at 17:11
-
As an aside, for this specific case, I'd consider using `virtualenv`. – c z Dec 18 '19 at 09:01
-
2`alias` or `symlink` is one option, but I think going with `update-alternatives` would be better. Since, you don't want to _update_ your `.bashrc` file time and again, nor make a bunch of **symlinks** for similar cases such as for `python3` and its different versions. – aspiring1 Mar 16 '20 at 08:02
12 Answers
-
2How can I find ~/.bashrc? I retagged my post based on your recommendation. – Ambitions Jun 09 '17 at 10:18
-
@Ambitions actually, this only concerns Linux/*nix (Mac including), so if you're using Windows, I can't help you. In unix based systems ~ stands for home directory (or if you don't use BASH it may be some other file like .zshrc ) – MacHala Jun 09 '17 at 10:24
-
1This does the trick for me in Ubuntu 18.04 as the .bashrc checks for .bash_aliases existence: `alias pip=pip3 >> ~/.bash_aliases` – TeddybearCrisis Jul 02 '19 at 07:29
-
alias pip=pip3 >> ~/.bash_aliases worked for me, thank you TeddybearCrisis – user3424037 Dec 27 '19 at 10:55
-
@Ambitions For MacOS, goto Macintosh HD/Users/yourname/ directory. Putting this alias in any .bashrc or .bash_profile would work. – Jimmy Shaw Mar 28 '20 at 22:14
-
2This is the wrong answer. And a bad approach. The correct way would be to use `update-alternatives`. Check @c-z's answer. – Qumber Aug 01 '20 at 13:26
-
@Qumber do you really think that "right approach" is the one that works only on select Linux distributions and requires root privileges? – MacHala Aug 25 '20 at 14:53
-
-
it worked for me well, but whe I input the command inside a `bash` file I still receive a `pip: command not found` error – Leonardo Rick Jan 29 '21 at 17:47
Rather than manually creating your own alias in bash and hoping this doesn't conflict with anything, most package managers should allow you to register the version you wish to use whilst maintaining dependencies.
For instance on Linux:
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
Or on Mac (MacPorts):
port select --set pip pip3

- 7,726
- 3
- 46
- 59
-
1Selecting 'pip3' for 'pip' failed: The specified group 'pip' does not exist. – user3424037 Dec 27 '19 at 10:43
-
@user3424037 Could be an older version of MacPorts (which didn't support this - see https://stackoverflow.com/questions/12557114/macports-and-the-bash-path), or Pip has been installed by a method other than MacPorts. – c z Jan 17 '20 at 10:39
-
1@ndemarco As far as I'm aware it just creates a link and then tracks that link to make sure it is updated when the application is updated, removed when the application is removed, and doesn't conflict with another application. The technical details of this process I'm not sure of and probably depend on the package manager. I've found Macports in particular is quite good at handling different versions of Python side-by-side, keeping the binaries separate but helpfully telling the user to (re-)run the `--set` command if they'd like to change the default version that is used. – c z Jul 24 '20 at 07:44
-
7I can confirm that the Linux statement works. Best answer. Why change the .bashrc with alias like the accepted answer suggests, this here seems more professional. – questionto42 Dec 16 '20 at 22:51
-
3questionto42, more professional (update-alternatives) and easier to be automated, I would say... the other solution I would say it is more error-prone. Agree, this should be the selected answer. – xCovelus Feb 11 '21 at 15:08
-
Now just do pip3 install --upgrade pip that will remove pip2, if you are lucky! Case here on Debian Testing! Python 2 is gone. – Валерий Заподовников May 24 '21 at 09:44
Solution 1
Check which version pip is pointing to
pip --version
pip 18.0 from /usr/lib/python2.7/site-packages/pip (python 2.7)
If your pip
is pointing to pip2
, locate where is the pip "binary".
which pip
/usr/bin/pip
This is a simple python script:
cat /usr/bin/pip
#!/usr/bin/python2
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(main())
So just change the shebang from #!/usr/bin/python2
to #!/usr/bin/python3
.
Now pip
is pointing to pip3
.
pip --version
pip 18.0 from /usr/lib/python3.6/site-packages/pip (python 3.6)
Solution 2
Remove /usr/bin/pip
make make a symbolic link from the wanted pip version to it instead.
sudo rm /usr/bin/pip
sudo ln -s /usr/bin/pip3.6 /usr/bin/pip

- 3,964
- 1
- 30
- 38
-
1re: Solution 2, It's worthwhile to note that since El Capitan you have to use `sudo ln -s /usr/bin/pip3 /usr/local/bin/pip` (you might have to `sudo mkdir -p /usr/local/bin` first if `/usr/local/bin` doesn't exist) see: stackoverflow.com/a/36734569/2764290 – Gifford N. Nov 24 '21 at 21:27
Since you uninstalled pip
, this solution assumes you're only going to use pip3
.
Open your terminal.
Create a simple link. To do that type:
sudo ln -s /usr/bin/pip3 /usr/bin/pip
Now when you type pip
, it will invoke pip3
.
Check that it worked by typing pip --version
pip --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
You're all set!
-
-
It's worthwhile to note that since El Capitan you have to use `sudo ln -s /usr/bin/pip3 /usr/local/bin/pip` (you might have to `sudo mkdir -p /usr/local/bin` first if `/usr/local/bin` doesn't exist) see: https://stackoverflow.com/a/36734569/2764290 – Gifford N. Nov 24 '21 at 21:26
You can install pip
after install pip3
by the below command:
pip3 install --upgrade pip
after that:
~ pip --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

- 1,556
- 1
- 20
- 39
You can write pip for pip3 after changing bashrc file in the home directory.
In mac -
Open bashrc file -
vim ~/.bashrc
Add this line at the end of the file -
alias pip="pip3"
Close the file. Don't forget to source this file in the terminal by
source ~/.bashrc
You are good to go. Now, whenever you will use pip in any command. it will be interpreted as pip3
You can check it by running the command -
pip --version

- 355
- 5
- 15
-
This repeats the core solution of the accepted answer of MacHala. A bit looking at the posting dates: Though this answer explains a bit more what to do with it, I do not see an upvote here for an answer 2 years after the accepted answer. A comment / edit would have done it. Apart from that. The probably best answer is that of @cz which was also before this one. – questionto42 Dec 17 '20 at 00:25
Pip is installed in /usr/bin/. If you don't have pip at all, I would suggest to install pip3 only. Make sure you don't need older version.
You can check available pip versions using following command.
ls /usr/bin/pip*
If you have multiple pip you need to prioritize your pip versions. I had only pip3 so I add it to the first priority. You can use following command and it is done.
sudo update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
You will get output as :
update-alternatives: using /usr/bin/pip3 to provide /usr/bin/pip (pip) in auto mode
Test now:
pip --version
You will get: pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
If you have other version for python2.7, you can use same update command and change last digit 1 to 2. This will make it second priority.

- 119
- 1
- 6
I believe one shouldn't do such a thing. Actually I would argue it's even better to not use the pip
, pip3
, etc. scripts ever. Instead one should always prefer the more explicit and surefire way of using pip's executable module for one specific Python interpreter:
path/to/pythonX.Y -m pip somecommand
References:

- 18,409
- 2
- 39
- 70
-
1I was happy to have this answer remind me that, even though I installed `pip3` via my package manager (`apt`) rather than `python -m ensurepip` (which wasn't available on my distro), once `pip3` is installed, `python -m pip` works (assuming that python points to my python3). – teichert Jan 22 '21 at 23:21
This can be done by simply creating an alias for the command. To create an alias just type
$alias new_command="existing_command"
In your case,
$alias pip="pip3"
Although this isn't permanent. OT make it permanent edit your bashrc file
$ vim ~/.bashrc
an to the end of it append the line.
$alias pip="pip3"

- 480
- 3
- 11
It depends on how you manage your python versions (system, brew, pyenv, ...) and which python installation you are currently using.
For example if you use brew then creating a simlink is a good option:
ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip
validate that pip uses the correct version:
which pip
will give you
/usr/local/bin/pip

- 2,964
- 3
- 25
- 47
Open the shell configuration file (such as .bashrc or .bash_profile) in a text editor.
For example open it with nano sudo nano .bash_profile
or with vim vim .bash_profile
.
Add this function, which checks if pip3 exists and pass all the arguments received by the pip function to pip3:
function pip {
if [[ $(which pip3) ]]; then
pip3 "$@"
else
echo "pip3 command not found. Make sure Python 3 and pip3 are installed."
fi
}
If pip3 is not found (i.e., it doesn't exist on your system), it displays an error message indicating that pip3 is not available.

- 604
- 4
- 14
Copy the pip3 file and rename as pip:
sudo cp /usr/bin/pip3 /usr/bin/pip
pip --version
and
pip3 --version
Works now.

- 7,102
- 69
- 48
- 77
-
1it's really better to symlink as described in [this answer](https://stackoverflow.com/a/56512469/2764290) – Gifford N. Nov 24 '21 at 21:28