Python added to PATH, cannot be directly accessed, cannot install pip

Mats Wichmann mats at wichmann.us
Mon Sep 27 15:43:34 EDT 2021


On 9/27/21 08:00, Will wrote:
>     Hello team at python.org,
> 
> 
> 
>     I've asked this question on a forum and tried to figure it out myself, but
>     I'm at a dead end. I don't know if you guys answer questions like this but
>     I have no where else to turn to.
> 
> 
> 
>     I am using a Lenovo Laptop using Windows. I'm trying to install
>     get-pip.py, and when I enter "python get-pip.py" into the Command Prompt,
>     it says "Python was not found; run without arguments to install from the
>     Microsoft Store, or disable this shortcut from Settings > Manage App
>     Execution Aliases."
> 
> 
> 
>     So for a week, I've been trying to add Python to PATH, so I can install
>     get-pip.py to Python.
> 
> 
> 
>     I've added the exact file location for Python to Path in both User
>     Variables and System Variables. I've executed Manage App Execution
>     Aliases, turned off both App Installer python.exe and App Installer
>     python3.exe. Still can't install pip, Python was still not found. I've
>     tried different keywords ("py get-pip.py", python3 get-pip.py", etc.).
>     Still doesn't work.
> 
> 
> 
>     Python is added to PATH and I can still run Python scripts, but I can't
>     find Python directly through the Command Prompt, and I cannot install
>     get-pip.py to Python.
> 
> 
> 
>     For reference, I have Python version 3.9.6 and I installed Python directly
>     from the site (I did not use Anaconda).
> 
> 
> 
>     Can you guys help me with this? Or do I need to delete Python and
>     reinstall it?

In addition to Eryk's comments...

Try invoking Python from a command prompt by typing "py" (I think you 
knew this).  For a python.org installation, as long as you didn't 
deselect the installation of the Python Launcher, that's the way to 
launch it.  Meanwhile, you can also install from the Microsoft Store - 
and the message you're getting is from the little stub that tries to be 
helpful about telling you this when you try as "python" - that's not 
Python itself that's running, it's the Windows helper.

pip, meanwhile, is not in the same directory as the python executable, 
so even "adding python to PATH" doesn't solve the problem of running 
pip.  Invoke it like this instead:

py -m pip install foo


you _can_ add the scripts subdirectory of the python install location to 
PATH as well, but it's better to get in the habit of running pip as a 
module, because it works way better once you have multiple pythons 
installed (which happens a lot).



More information about the Python-list mailing list