17

I'm trying to get pip to point to a different install rather than the default. It is currently pointing to /usr/bin/pip, but I want it to point to /usr/local/bin/pip. I believe I have the path set correctly and everything else points to the correct location.

What's the best way to resolve this?

# echo $PATH
/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin

# which python
/usr/local/bin/python

# which easy_install
/usr/local/bin/easy_install

# which pip
/usr/bin/pip

5 Answers5

8

Using 'alias' is another possible option. Just put it into the relevant shell configuration file (for execution each time your shell is executed).

$ alias pip='/usr/bin/pip'
$ alias pip
alias pip='/usr/bin/pip'
$ alias pip='/usr/local/bin/pip'
$ alias pip
alias pip='/usr/local/bin/pip'
$ pip
bash: /usr/local/bin/pip: No such file or directory
dtbnguyen
  • 635
  • 3
  • 7
6

It seems that you have both pip installed via easy_install and OS package manager. If you want to use only one, just remove another one.

In your case, you want pip from easy_install, so just removing which one from OS package manager.

With Debian/Ubuntu:

sudo apt-get purge python-pip

With Redhat/Centos/Fedora:

sudo yum remove python-pip
cuonglm
  • 150,973
  • 38
  • 327
  • 406
4

You can specify PATH to local pip in ~/.bash_profile file. Supposed that you you would like to use pip from /usr/local/bin/pip, you can add export PATH=$HOME/usr/local/bin:$PATH to the file. This will add the desired PATH to existing PATH ($PATH).

Then, source ~/.bash_profile to update the PATH.

Check pippath again by typing which pip.

2

Nobody mentioned this here but a symlink would do the trick as well. In my case since /usr/bin is the default path for every program, just make the pip symlink point to the correct pip executable.

Gilson
  • 121
  • 2
0

Edit your ~/.bashrc file to include the path to your preferred pip installation. E.g.

alias pip='/usr/bin/pip'

Then source your .bashrc file for it to come into action.

source ~/.bashrc

Check: which pip

/usr/bin/pip

user7194913
  • 111
  • 1