Hello, if you install Python from official installer you need to add Python executable to PATH, This article have good explanation for that [image] How to Add Python to PATH – Real Python In this tutorial, you'll learn about how to add Python, or any other program, to your PATH environm… Answer from gunungpw on discuss.python.org
Discussions

windows 10 - 'Python not found' despite having been installed - Stack Overflow
And, before you ask, all my various ... (Build #PY-231.9011.38, built on May 16, 2023) and Visual Studio Code 1.78.2 (user setup) work just fine with Python files. This is something quirky with Windows 11 and an apparent bug in the way right-click Open in Terminal fails to work correctly when passing along the proper environment information to the instance of Windows Terminal it opens. ... Ok, you basically re-analyzed the problem, but didn't provide ... More on stackoverflow.com
🌐 stackoverflow.com
environment variables - 'py' works but not 'python' in command prompt for windows 10 - Stack Overflow
Bring the best of human thought ... at your work. Explore Stack Internal ... Closed 5 years ago. I installed Python on my computer. When I type python in the command prompt I get the following message: 'python' is not recognized as an internal or external command, operable program or batch file. But when I type py it seems to ... More on stackoverflow.com
🌐 stackoverflow.com
Python works, "py" doesn't
Show the results of running these commands. echo %PATH% where py dir c:\windows\py.exe More on reddit.com
🌐 r/learnpython
35
0
June 12, 2024
Python: command not found
Hi I’m very new to Python and I’m trying to get it set up with VSC, however I keep getting the following error whenever I try to run any commands: /bin/sh: python: command not found I’ve googled and tried solutions such as installing homebrew, but to no avail. More on discuss.python.org
🌐 discuss.python.org
2
0
December 28, 2022
Top answer
1 of 16
145

I have installed the latest Python for Win10 from Releases for Windows. Just typing py in the Command Prompt Window starts Python.

Microsoft Windows [Version 10.0.15048]
(c) 2017 Microsoft Corporation. All rights reserved.

C:\Users\sg7>py
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>`enter code here`

Testing:

>>> print("hello!")
hello!
>>>

Please be aware that in my case Python was installed in C:\Users\sg7\AppData\Local\Programs\Python\Python36> directory

C:\Users\sg7\AppData\Local\Programs\Python\Python36>dir
 Volume in drive C is Windows7_OS
 Volume Serial Number is 1226-12D1

 Directory of C:\Users\sg7\AppData\Local\Programs\Python\Python36

08/05/2018  07:38 AM    <DIR>          .
08/05/2018  07:38 AM    <DIR>          ..
12/18/2017  09:12 AM    <DIR>          DLLs
12/18/2017  09:12 AM    <DIR>          Doc
12/18/2017  09:12 AM    <DIR>          include
12/18/2017  09:12 AM    <DIR>          Lib
12/18/2017  09:12 AM    <DIR>          libs
10/03/2017  07:17 PM            30,334 LICENSE.txt
10/03/2017  07:17 PM           362,094 NEWS.txt
10/03/2017  07:15 PM           100,504 python.exe
10/03/2017  07:12 PM            58,520 python3.dll
10/03/2017  07:12 PM         3,610,776 python36.dll
10/03/2017  07:15 PM            98,968 pythonw.exe
08/05/2018  07:38 AM           196,096 Removescons.exe
08/05/2018  07:38 AM            26,563 scons-wininst.log
08/05/2018  07:38 AM    <DIR>          Scripts
12/18/2017  09:12 AM    <DIR>          tcl
12/18/2017  09:12 AM    <DIR>          Tools
06/09/2016  11:53 PM            87,888 vcruntime140.dll
               9 File(s)      4,571,743 bytes
              10 Dir(s)  20,228,898,816 bytes free

When I am at C:\Users\sg7> directory level python can be invoked by typing AppData\Local\Programs\Python\Python36\python

C:\Users\samg>AppData\Local\Programs\Python\Python36\python
Python 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Newer Python 3.7 will be installed at: C:\Users\YourUserNameHere\AppData\Local\Programs\Python\Python37

If you wish you can add to your path environment variable: %USERPROFILE%\AppData\Local\Programs\Python\Python36

2 of 16
109

It finally worked!!!

I needed to do things to get it to work

  1. Add C:\Python27\ to the end of the PATH system variable
  2. Add C:\Python27\ to the end of the PYTHONPATH system variable

I had to add these to both for it to work.

If I added any subdirectories, it did not work for some reason.

Thank you all for your responses.

Top answer
1 of 5
65

As suggested in comments, you could create an alias as follows:

alias python='python3'

by adding it to the ~/.bashrc file at the end of this file, exiting and reloading it in the current terminal using the next command: . ~/.bashrc

Or using linking:

As you can see below, my python points to python2, python2 points to python2.7.

To achieve the same, use:

sudo ln -s /usr/bin/python2.7 /usr/bin/python2 
sudo ln -s /usr/bin/python2 /usr/bin/python

If you want python pointing to 3rd version, you could use the same, but the last command should be:

sudo ln -s /usr/bin/python3 /usr/bin/python

Example

$ whereis python
python: /usr/bin/python3.7 /usr/bin/python2.7-config /usr/bin/python2.7 /usr/bin/python3.7m-config /usr/bin/python3.7-config /usr/bin/python /usr/bin/python3.7m /usr/lib/python3.7 /usr/lib/python2.7 /usr/lib/python3.8 /etc/python3.7 /etc/python2.7 /etc/python /usr/local/lib/python3.7 /usr/local/lib/python2.7 /usr/include/python3.7 /usr/include/python2.7 /usr/include/python3.7m /usr/share/python /usr/share/man/man1/python.1.gz
user@lenovo:~$ ls -ailh /usr/bin/python*
1446954 lrwxrwxrwx 1 root root    7 жов 10 14:32 /usr/bin/python -> python2
1446952 lrwxrwxrwx 1 root root    9 жов 10 14:32 /usr/bin/python2 -> python2.7
1465834 -rwxr-xr-x 1 root root 3,6M лис  7 12:07 /usr/bin/python2.7
1447155 lrwxrwxrwx 1 root root   33 лис  7 12:07 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
1447156 lrwxrwxrwx 1 root root   16 жов 10 14:32 /usr/bin/python2-config -> python2.7-config
1442842 lrwxrwxrwx 1 root root    9 лют 12 00:23 /usr/bin/python3 -> python3.7
1449245 -rwxr-xr-x 2 root root 4,9M лис 20 11:21 /usr/bin/python3.7
1447339 lrwxrwxrwx 1 root root   33 ли 20 11:21 /usr/bin/python3.7-config -> x86_64-linux-gnu-python3.7-config
1449245 -rwxr-xr-x 2 root root 4,9M лис 20 11:21 /usr/bin/python3.7m
1447340 lrwxrwxrwx 1 root root   34 лис 20 11:21 /usr/bin/python3.7m-config -> x86_64-linux-gnu-python3.7m-config
1447341 lrwxrwxrwx 1 root root   16 жов  2 15:31 /usr/bin/python3-config -> python3.7-config
1442843 -rwxr-xr-x 1 root root  384 січ 30  2019 /usr/bin/python3-futurize
1442847 lrwxrwxrwx 1 root root   10 лют 12 00:23 /usr/bin/python3m -> python3.7m
1447342 lrwxrwxrwx 1 root root   17 жов  2 15:31 /usr/bin/python3m-config -> python3.7m-config
1442844 -rwxr-xr-x 1 root root  388 січ 30  2019 /usr/bin/python3-pasteurize
1447157 lrwxrwxrwx 1 root root   14 жов 10 14:32 /usr/bin/python-config -> python2-config
1455649 lrwxrwxrwx 1 root root   58 лип 10  2019 /usr/bin/pythontex -> ../share/texlive/texmf-dist/scripts/pythontex/pythontex.py
1450999 -rwxr-xr-x 1 root root  306 лип 10  2019 /usr/bin/pythontex3

For managing python3 versions, you can use python alternatives to create symbolic links:

$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2

And choose which one to use as using the command:

$ sudo update-alternatives --config python3

For managing python2 and python3 using update-alternatives, you could see in michael's answer.

2 of 5
53

This solution only applies to Ubuntu 20.04 (but sometimes people look at "similar issues" for a solution).

In the case you like python to refer to python3, you can simply install python-is-python3:

sudo apt-get install python-is-python3

After this, invoking python will work just fine.

Find elsewhere
🌐
Reddit
reddit.com › r/learnpython › python works, "py" doesn't
r/learnpython on Reddit: Python works, "py" doesn't
June 12, 2024 -

I'm running a windows 10 machine with Python 3.12 installed. For some reason the 'python' command works fine, but 'py' gets me "'py' is not recognized as an internal or external command, operable program or batch file."

I have python installed here: C:\Users[username]\AppData\Local\Programs\Python\Python312

And the python launcher installed here: C:\Windows\py.exe

I've added both locations to my PATH, restarted the machine, but still doesn't work.

Any help is appreciated.

🌐
C# Corner
c-sharpcorner.com › article › python-py-works-but-python-doesnt
Python -- "py" works, but "python" doesn't
June 2, 2023 - The reason is the command python does not set up the environment PATH correctly, while py does because py is itself located in C:\Windows that is always part of the PATH, which is why you found it.
🌐
CodeWithHarry
codewithharry.com › blogpost › solving-python-not-found-run-without-arguments
[Solved] python was not found; run without arguments to install from the microsoft store, or... | Blog | CodeWithHarry
First, you need to find the paths where your Python interpreter is installed. The paths are usually one of the below: ... But if you are having trouble finding your Python installation, here is a quick guide I wrote for exactly that.
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to fix the "python: command not found" error
How to Fix the "python: command not found" Error
December 11, 2025 - The python: command not found error occurs when the system cannot find the Python executable file, preventing users from executing Python commands or running scripts.
🌐
DEV Community
dev.to › abidcomsian › how-to-fix-python-was-not-found-error-on-windows-disable-app-execution-aliases-2mj6
How to Fix “Python Was Not Found” Error on Windows: Disable App Execution Aliases - DEV Community
July 24, 2025 - "Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Apps > Advanced app settings > App execution aliases."
🌐
Python.org
discuss.python.org › python help
Python: command not found - Python Help - Discussions on Python.org
December 28, 2022 - Hi I’m very new to Python and I’m trying to get it set up with VSC, however I keep getting the following error whenever I try to run any commands: /bin/sh: python: command not found I’ve googled and tried solutions suc…
🌐
nixCraft
cyberciti.biz › nixcraft › howto › bash shell › -bash: python: command not found error and solution
-bash: python: command not found error and solution - nixCraft
July 22, 2023 - Fig.01: Python command not found It seems that Python is missing for an unknown reason or was not installed by my cloud provider to save the disk space. So install it as per your Linux distro or Unix variant: ... Than you for your help. My issue was a broken symlink but I have been able to fix it with this line.
🌐
GeeksforGeeks
geeksforgeeks.org › linux-unix › how-to-resolve-python-command-not-found-error-in-linux
How to Resolve Python Command Not Found Error in Linux - GeeksforGeeks
February 28, 2024 - Getting the "Python command not found" error in Linux usually means Python is missing or not properly set up on your system. This common issue can be caused by missing installations, incorrect PATH settings, or version mismatches.
🌐
Quora
quora.com › Why-is-Python-not-working-in-CMD
Why is Python not working in CMD? - Quora
Answer: Have you checked your path variable? If python is not in the path variable, it will not work. To check, 1. Open Control Panel 2. Navigate to System 3. Go in advanced system settings 4. Go in environment variables 5. In System variables, search for path. 6.Double click on path to open e...