termux-packages icon indicating copy to clipboard operation
termux-packages copied to clipboard

pip and pip2 both point to 2.7 if both python and python2 are installed

Open tigran123 opened this issue 10 years ago • 9 comments

I installed both python and python2 packages (as well as their "-dev" and a myriad of other packages, almost everything in termux.com's repository) and noticed that initially pip and pip2 point to 3.5 and 2.7 respectively. This is good. But then if I try to upgrade pip2 (by pip2 install --upgrade pip) then pip no longer points to 3.5 --- both pip and pip2 now point to 2.7, look:

$ pip -V
pip 8.1.2 from /data/data/com.termux/files/usr/lib/python2.7/site-packages (python 2.7)
$ pip2 -V
pip 8.1.2 from /data/data/com.termux/files/usr/lib/python2.7/site-packages (python 2.7)

I am using Termux v0.40 and everything is freshly installed today (on the Genymotion emulator)

tigran123 avatar Sep 05 '16 07:09 tigran123

I've had that. It's because you updated pip2. If you update pip2 it will overwrite pip, breaking everything.

Neo-Oli avatar Sep 05 '16 07:09 Neo-Oli

Hm, I guess that --no-default-pip should be given to pip2 when updating to avoid it overwriting pip.

It would be nice if one could configure pip2 to remember that configuration.

fornwall avatar Sep 05 '16 10:09 fornwall

@fornwall Attempting to pass --no-default-pip option results in no such option: --no-default-pip error.

tigran123 avatar Sep 05 '16 10:09 tigran123

Aha, I was using python2 -m ensurepip --upgrade --no-default-pip, but perhaps the pip2 tool doesn't support something similar?

A current workaround is to skip pip/pip3/pip2 and run python -m pip, like in:

python -m pip install httpie
python2 -m pip install httpie

Related discussion: https://github.com/pypa/pip/issues/3164

fornwall avatar Sep 05 '16 10:09 fornwall

@fornwall Thank you, I've learned something new :)

tigran123 avatar Sep 05 '16 10:09 tigran123

Hi all,

I just ask a question at https://github.com/pypa/pip/issues/4276 (By default, which version of python should pip point to? python 2.7, python 3.5 pip 9.0.1)

Maybe you can chime in as it relates to this topic of discussion.

whimsyniche avatar Feb 10 '17 18:02 whimsyniche

On any computer you can discover what pip is like this:

$ type pip
pip is /usr/local/bin/pip
$ cat /usr/local/bin/pip
#!/usr/local/bin/python3.6

# -*- coding: utf-8 -*-
import re
import sys

from pip import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

As you see, pip is just a python script and the version of python which it corresponds to is entirely determined by the interpreter which is listed on the first line.

tigran123 avatar Feb 10 '17 19:02 tigran123

We need to stick with pip 10.0 . Upgrading pip to 18.0 causes this bug.

b3nsh4 avatar Sep 23 '18 17:09 b3nsh4

By default package python2 provides pip2 and pip2.7. Package python (v3.7) provides pip, pip3 and pip3.7.

So problem perhaps fixed.

Upgrading pip to 18.0 causes this bug.

Pip is installed via python -m ensurepip --upgrade --default-pip, so default pip version is reasonable and shouldn't be upgraded to avoid potential problems.

ghost avatar Jan 18 '19 21:01 ghost