Loading video player…

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.