3

I'm sshing into a Linux server as a user. Somehow, the server has Python 2.7.5 installed but doesn't respond to which pip.

So I tried to install pip using get-pip.py according to pip docs. The default install option seemed problematic:

$ python get-pip.py
OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/pip'

So I tried:

$ python get-pip.py --user
Collecting pip
  Using cached pip-9.0.1-py2.py3-none-any.whl
Collecting setuptools
  Using cached setuptools-28.8.0-py2.py3-none-any.whl
Collecting wheel
  Using cached wheel-0.29.0-py2.py3-none-any.whl
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-9.0.1 setuptools-28.8.0 wheel-0.29.0

But which pip still produces no pip in ...(my PATH). Where was it installed, can someone make a guess?

  • 2
    Run `find $HOME -name 'pip' -print`. That will tell you where it was installed, if it was installed correctly in your home directory. – Munir Nov 20 '16 at 21:57
  • Interesting, I found it in `~/.local/lib/python2.7/site-packages/pip` and added it to my PATH. Surprisingly, `which pip` still doesn't find it (`no pip in (...:[full path to ~/.local])`). – Elizabeth Chu Nov 20 '16 at 22:08
  • Don't use `~` when adding to PATH. Use `$HOME`. `~` expansion is limited to shell, and only when it is the first character in a word. See http://stackoverflow.com/questions/11587343/difference-between-home-and-tilde for details. – Munir Nov 20 '16 at 22:12
  • I didn't use `~`. It was "full path to ~/.local". – Elizabeth Chu Nov 20 '16 at 22:17
  • Did you reload/export your PATH variable? You need to `export $PATH` in your `.bash_profile` and then run `source .bash_profile` from the terminal to update your PATH. – Munir Nov 20 '16 at 22:27
  • Thanks @Munir; I did what you said but still it doesn't find it. I am planning to contact the system admin about it. – Elizabeth Chu Nov 20 '16 at 22:38
  • @ElizabethChu You've come across the package name, not the binary. The binary lives in `~/.local/lib/pip`. You can't execute the package, hence setting your `PATH` accordingly won't do anything. –  May 05 '17 at 06:40
  • 1
    Usually, this can also be solved using `python -m pip `, since `pip` is an executable module/package. This also ensures you have the correct pip version to go with the correct Python version, which is useful in cases where you have multiple versions of Python (2.7, 3.4, 3.5, ...) installed. –  May 05 '17 at 06:43

2 Answers2

3

If pip is installed via python get-pip.py --user, the executable should be located at $HOME/.local/bin/pip:

Update the path (e.g. in ~/.bashrc): PATH=$PATH:$HOME/.local/bin/

$ which pip ~/.local/bin/pip

nathanielng
  • 1,645
  • 1
  • 19
  • 30
  • This is correct, provided the `PATH` is set correctly. The second part may not work. –  May 05 '17 at 06:39
  • oh, sorry, I realise I left out the part about setting up the PATH. I will add it in to my answer. – nathanielng May 05 '17 at 06:47
0

I had the same problem but this command helped hash -r try and then use command which pip to see if pip will be located

shaddyshad
  • 217
  • 4
  • 15