Running Python on Windows
00:00
Starting out with Python on Windows can be a frustrating experience. Until Python 3.14, if you were to install Python with the official Python.org installer, and then you use the default settings and click Install Now, you wouldnât be able to use the python command from PowerShell.
00:19
Note that thereâs this little checkbox at the bottom here that says âAdd python.exe to PATH.â And a lot of people donât think to check it. Partly itâs because they donât know what that means. They maybe donât know what PATH is, and they donât know that you wonât be able to follow along with tutorials exactly if you donât click that box.
00:40
You install with the default settings, you go to PowerShell, try to type python in, itâs not found. python3, python3.13, none of those will work.
00:51
It might give you an error or it might open up the Windows Store instead of running the Python console like youâd expect. And most tutorials are going to use one of those commands in their examples, usually python3.
01:06 So you would think that just running the default installer and then following a tutorial, itâll just work, but it doesnât.
01:15
So why not? And why not make it the default to have that checkbox clicked? Thereâs some historical reasons for that, and thatâs because there are some differences with how PATH works on Windows versus how it works on Mac or Linux.
01:30
On Mac and Linux, PATH is updated automatically, and you can get the python3 command just by following the installer. So thatâs what most tutorials assume.
01:40
But with Windows, thereâs a max character limit on how long PATH can be. Thereâs also a security risk involved in updating PATH.
01:49
And thereâs kind of two different paths. Thereâs a user-specific one and a system-wide one. So for all of these reasons, it was decided long ago that users would have to opt in to adding Python to PATH as a little safeguard to show that they understood what it was and that there are risks involved with it.
02:09
So if you havenât already added Python to PATH, what are your options? One is that you can uninstall Python and reinstall it with that checkbox checked, or you can manually add Python to PATH.
02:24
For both of these options, you should watch the next two lessons so you know how to manage PATH on Windows. But those arenât your only options.
02:33 You could run the Python executable directly, though itâs a bit hard to find. Itâs installed in a kind of hidden location by default. Or the best way is to use the PyLauncher.
02:44
So this is using the py command, and this is a special program created for Windows so that you can run Python without editing PATH.
02:57
So to run the PyLauncher instead of the python command or python3 command, which gives this error, you can instead use the py command.
03:09
Running just py is going to run 3.13 for me because thatâs what I have installed on my machine,
03:18
and it opens up the Python console. If you had a file, then you could use py and then the file name to run the file. And then if you had multiple versions of Python, you can use py dash the version number.
03:33
So py -3.13 will open up 3.13 for me. And if I had 3.11 installed, then I can use py -3.11. Since I donât have 3.11 installed, I get this different error, âNo suitable Python runtime found.â If, however, py gives you the same error as before, saying that itâs not a valid command, then you probably donât have any version of Python installed, and you should do that first.
04:03 So this was the recommended way to run Python on versions 3.3 to 3.13. As of 3.14, though, theyâve released a new application called the Python Install Manager, and it kind of replaces the PyLauncher.
04:21
It uses the same py command, but it also allows you to install different versions of Python on your machine through the command line. So as of Python 3.16, this Install Manager is going to be the way to manage Python on your machine, and the standalone installer wonât even be around anymore.
04:43
Using the Python Install Manager, you can also create an alias so that the python command works, but thereâs a couple of additional steps. Some other options are downloading Python through the Windows Store or Anaconda.
04:58
Those will give you the python command out of the box. And then some more advanced options are using pyenv-win or uv, and these are a little more advanced.
05:10
They have more capabilities, but also require you to learn some other commands. Thatâs it. You may not need to add Python to PATH if you can just use the py command, but if you do want to add Python to PATH, then watch this next lesson, and weâll also discuss how to reorder or remove items from PATH if you need to troubleshoot some problems with it.
Become a Member to join the conversation.
