Search code examples
pythonpython-3.xwindowscmdpip

What are the advantages of "python.exe -m pip install" over "pip install" command?


        C:\Users\hp>pip install --upgrade pip
        Requirement already satisfied: pip in 
        c:\users\hp\appdata\local\programs\python\python311\lib\site-packages (23.1.2)
        Collecting pip
         Downloading pip-23.2.1-py3-none-any.whl (2.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 10.2 MB/s eta 0:00:00
        ERROR: To modify pip, please run the following command:
        C:\Users\hp\AppData\Local\Programs\Python\Python311\python.exe -m pip install -- 
       upgrade pip

        [notice] A new release of pip is available: 23.1.2 -> 23.2.1
        [notice] To update, run: python.exe -m pip install --upgrade pip

I get the above message when using pip install --upgrade pip, but when I use python.exe -m pip install--upgrade pip as mentioned in the notice, pip gets upgraded.

Can anyone tell me the difference between these two commands?


Solution

  • pip can't update pip.exe if pip.exe is already running, so you need to use a command that avoids running the pip.exe executable to update pip itself on Windows. Unix platforms don't have this limitation.