Search code examples
pythonterminalpipanaconda

What is -u used for in the code "pip install numpy -u"


I've searched a lot on the internet but still do not understand what the above line of code does. The question is in the title. Please Explain.


Solution

  • It may depend on the version of pip you're using. For me, there is no -u option:

    $ pip --version
    pip 22.1.2
    
    $ pip install numpy -u
    
    Usage:
      pip3 install [options]  [package-index-options] ...
      pip3 install [options] -r  [package-index-options] ...
      pip3 install [options] [-e]  ...
      pip3 install [options] [-e]  ...
      pip3 install [options]  ...
    
    no such option: -u
    

    It's possible you mean -U which is short for --upgrade.

    $ pip install --help
    ...
    Install Options:
      ...
      -U, --upgrade               Upgrade all specified packages to the newest
                                  available version. The handling of dependencies
      ...
    ...
    
    $ pip install numpy==1.22.0
    Collecting numpy==1.22.0
      Using cached numpy-1.22.0-cp310-cp310-win_amd64.whl (14.7 MB)
    Installing collected packages: numpy
    Successfully installed numpy-1.22.0
    
    pdunn@CHA-SHITEST11 /c/git/personal/python/pygame/game (master)
    $ pip install -U numpy
    Requirement already satisfied: numpy ... (1.22.0)
    Collecting numpy
      Using cached numpy-1.23.1-cp310-cp310-win_amd64.whl (14.6 MB)
    Installing collected packages: numpy
      Attempting uninstall: numpy
        Found existing installation: numpy 1.22.0
        Uninstalling numpy-1.22.0:
          Successfully uninstalled numpy-1.22.0
    Successfully installed numpy-1.23.1