Python 3 is not upgrading pip. Am I linking a wrong directory?

14,601

Solution 1

Just do the pip3 upgrade with sudo. I think you mixed up python2 and python3 installs with your sudo call. Just tested and gave me the correct version on pip3:

$ sudo pip3 install --upgrade pip
Collecting pip
  Downloading pip-20.3.1-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 2.6 MB/s 
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-20.3.1
$ pip3 --version
pip 20.3.1 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)

Tested on KDE Neon (Ubuntu 20.04). Also make sure you don't have another version of pip installed somewhere in the user installations. These easily get mixed up between apt and the user locations for python installs.

Solution 2

ou are using pip version 19.2.3, however version 20.3.4 is available. You should consider upgrading via the 'pip install --upgrade pip' command.

Share:
14,601
mad
Author by

mad

Updated on June 04, 2022

Comments

  • mad
    mad almost 2 years

    I have the following issue every time I try to install a package in Python 3:

    WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
    You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command
    

    I tried to do the upgrade pip command as follows, with the also following warning:

    $ pip3 install --upgrade pip
    
    Collecting pip
      Using cached pip-20.3.1-py2.py3-none-any.whl (1.5 MB)
    Installing collected packages: pip
    Successfully installed pip-20.3.1
    WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
    You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command
    

    I tried the other way, with the same error:

    $ /usr/bin/python3 -m pip install --upgrade pip
    
    Collecting pip
    Using cached pip-20.3.1-py2.py3-none-any.whl (1.5 MB)
    Installing collected packages: pip
    Successfully installed pip-20.3.1
    WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
    You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command
    

    I also tried the Following suggestion to solve this problem, downloading the package and ask pip to install directly from the .tar.gz file:

    $sudo python3 -m pip install /home/me/Downloads/pip-20.3.1.tar.gz 
    
    [sudo] password for me: 
    Processing /home/me/Downloads/pip-20.3.1.tar.gz
      Installing build dependencies ... done
      Getting requirements to build wheel ... done
        Preparing wheel metadata ... done
    Building wheels for collected packages: pip
      Building wheel for pip (PEP 517) ... done
      Created wheel for pip: filename=pip-20.3.1-py2.py3-none-any.whl size=1518515 sha256=36207044a2b9042728f3cd0f971569217f4e2e9c68c84adbf5c42617e08b9d3c
      Stored in directory: /root/.cache/pip/wheels/0e/09/b2/4673e6d2eee911dbbeaeeba8e68eebb9719b1b3ba25ad93e2c
    Successfully built pip
    Installing collected packages: pip
      Attempting uninstall: pip
        Found existing installation: pip 20.0.2
        Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
        Can't uninstall 'pip'. No files were found to uninstall.
    Successfully installed pip-20.3.1
    

    Again, the same error happens:

    $pip3 install pydot
    
    Collecting pydot
    Using cached pydot-1.4.1-py2.py3-none-any.whl (19 kB)
    Collecting pyparsing>=2.1.4
    Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
    Installing collected packages: pyparsing, pydot
    Successfully installed pydot-1.4.1 pyparsing-2.4.7
    
    WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
    You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
    

    My Python versions are:

    $python --version
    Python 3.7.9
    
    $python3 --version
    Python 3.8.5
    

    My PATH variable links the following directories:

    $echo $PATH
    
    /home/me/.local/bin:/home/me/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
    :/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
    

    What is happening here? should I have to add something to my PATH variable in order to link the right python version to the pip upgrade command? or there is something else to be done?

  • mad
    mad over 3 years
    It works. However, I always need to use sudo to install any pip3 package. Any workaround on this? thank you.
  • FloWil
    FloWil over 3 years
    I guess that's because you have the pip3 installed by apt and that requires root privileges to do. I would suggest to workaround this by using any form of virtualenv or virtualenv based package management like pipenv and/or poetry. These then can install any packages and dependencies per project and that should not require any root privileges. Another way may to be force the system-wide pip to install to your user-based package installation.