3

Could someone please kindly explain to me, why installing python3-pip package with apt installs pip3 for... python 2?

$ pip3 --version
pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
$ which pip3 | xargs head -n 1
#!/usr/bin/python
$ ls /usr/bin/python
lrwxrwxrwx 1 root root 9 maj 18  2016 /usr/bin/python -> python2.7

I don't know if this should be troubling me this much, but to be in line with XY problem solving: I'm asking because due to this particular setup, many pip3 installs fail - for example, after sudo -H pip3 install docker-compose:

$ docker-compose
Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 7, in <module>
    from compose.cli.main import main
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 20, in <module>
    from ..bundle import get_image_digests
  File "/usr/local/lib/python2.7/dist-packages/compose/bundle.py", line 14, in <module>
    from .service import format_environment
  File "/usr/local/lib/python2.7/dist-packages/compose/service.py", line 14, in <module>
    from docker.utils import LogConfig
ImportError: cannot import name LogConfig

I'm running Ubuntu GNOME 16.04

5
  • I don't know where you got pip3 from, but python3-pip contains this as /usr/bin/pip3: paste.ubuntu.com/23667201 Download from packages.ubuntu.com/xenial/all/python3-pip/download and see for yourself. Further, why do you have anything Python-related in /usr/local at all? It looks like you install Python from source and messed up.
    – muru
    Dec 22, 2016 at 4:58
  • @muru The package landed inside /usr/local after clean reinstall of both the pip and package itself. I have no idea why that happened. python3-pip package came from pl.archive.ubuntu.com_ubuntu_dists_xenial_universe_binary-amd64_Packages (as in pool/universe/p/python-pip/python3-pip_8.1.1-2ubuntu0.4_all.deb). Dec 22, 2016 at 5:35
  • sorry, but packages from official repos never install anything in /usr/local.
    – muru
    Dec 22, 2016 at 5:49
  • @muru The /usr/local/ one is not the one from official repo. python3-pip is, pip3 actually installed it there. For some reason. I reinstalled that with python3 -m pip install and it worked as expected. At this point I am afraid to even ask why. Dec 22, 2016 at 6:53
  • 1
    I fixed docker-compose Python issue with sudo -H pip install --upgrade docker-py. Sep 19, 2018 at 23:25

1 Answer 1

4

Did u try - sudo -H python3 -m pip install ..?

Doing python3 -m pip will explicitly invoke python3's pip.

Sorry for posting this as answer. I don't have enough reputation to put a comment.

1
  • 1
    I know about the command, but the pip3 thing got me by surprise. By now I'm not sure about the state of any python dependency I installed with pip3, and that makes me kinda nervous. I really wanted to just know why anyone would want that... Dec 22, 2016 at 4:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .