Search code examples
pythonpowershellpipcommand-promptreinstall

How to install pip back into a windows PowerShell and Command Prompt list of commands?


Yesterday I accidentally deleted my pip command on windows 11 and I'm wondering how to reinstall it without having to reinstall python. I find it impossible to install some Python modules, frameworks and packages on Command Prompt and PowerShell(I tried both).During the attempts, the two apps stated that pip is not recognized as any command, The Developer VS 2022 version(which I have, because I use Visual Studio 2022) stated the same(my Start Command Prompt With Ruby also stated the same) and I can't really enter my Administrators because they make changes to my laptop. Do you have any ideas how I can reinstall pip?


Solution

  • Have you tried using get-pip.py to reinstall pip?

    I would recommend reading about get-pip.py first before doing this, but the process shouldn't be difficult.

    https://pip.pypa.io/en/stable/installation/

    1. Download get-pip.py (assuming windows 11, powershell)
    wget -uri https://bootstrap.pypa.io/get-pip.py -OutFile get-pip.py
    

    alternatively you could use save as the file and save it to your machine.

    1. Install pip
    python get-pip.py
    

    Full output:

    PS C:\Users\Jerem> python get-pip.py
    Collecting pip
      Using cached pip-23.3.2-py3-none-any.whl.metadata (3.5 kB)
    Using cached pip-23.3.2-py3-none-any.whl (2.1 MB)
    Installing collected packages: pip
      Attempting uninstall: pip
        Found existing installation: pip 23.3.2
        Uninstalling pip-23.3.2:
          Successfully uninstalled pip-23.3.2
    Successfully installed pip-23.3.2
    

    Test that its working

    PS C:\Users\Jerem> python -m pip --version
    pip 23.3.2 from C:\Users\Jerem\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip (python 3.11)