Pip3 is actually running python2?

5,193

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.

Share:
5,193

Related videos on Youtube

Błażej Michalik
Author by

Błażej Michalik

Updated on September 18, 2022

Comments

  • Błażej Michalik
    Błażej Michalik almost 2 years

    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

    • muru
      muru over 7 years
      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.
    • Błażej Michalik
      Błażej Michalik over 7 years
      @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-am‌​d64_Packages (as in pool/universe/p/python-pip/python3-pip_8.1.1-2ubuntu0.4_all.‌​deb).
    • muru
      muru over 7 years
      sorry, but packages from official repos never install anything in /usr/local.
    • Błażej Michalik
      Błażej Michalik over 7 years
      @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.
    • Pablo Bianchi
      Pablo Bianchi almost 6 years
      I fixed docker-compose Python issue with sudo -H pip install --upgrade docker-py.
  • Błażej Michalik
    Błażej Michalik over 7 years
    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...