Visual Studio Code for Python Developers Transcripts
Chapter: Editing Python Code with VS Code
Lecture: Installing and Using the Python Extension

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Alright, back over in Visual Studio Code, we're going to install the Python extension.
0:04 One of the ways that might be possible is Visual Studio Code might notify you in the bottom right-hand corner under the notifications to install it that way.
0:12 And in this particular project, that's happening because we have it as a recommended extension.
0:16 But if that doesn't happen for you, you can come over to the extensions view, which is those little blocks typically with the default themes and icons, and search for Python here.
0:25 Once that loads up, you click on this Python one. Again, remember, it's the one from Microsoft themselves with over 100 million downloads.
0:33 We're going to click install on that. And once that's done, that was quick and easy. It's installed and ready to go.
0:40 Let's take a look at the different experience now in Visual Studio Code.
0:44 Now, when we come back over here, remember, it gave the syntax highlighting of print. But notice what might change as I'm typing this out.
0:53 You see this quick little IntelliSense auto-completion showing options for how to complete. And I can see what I'm typing.
1:00 So I have to type less and I can just press tab or enter and it will fill in the rest of that command for me. From here, you can go hello world again.
1:10 Save it. I can hover over the print function and I get more details about what this does. What are the parameters that this function is expecting?
1:19 And I can learn more about how to use it more properly. What are the options I have within it?
1:23 All driven through the Python extension in Visual Studio Code that you would not have in the default experience.
1:29 Let's talk about some of the settings that are available with the extension as well.
1:32 So I'm going to open this up the settings with the keyboard shortcut control comma or command comma. If you're on macOS.
1:39 I'm going to search for Python.
1:41 Once I'm in here, you'll notice that there's a couple of different options, but we're going to focus on under the extensions category Python.
1:50 And you'll see there's a lot of options here.
1:52 One that I highly recommend that's a relatively new feature in Visual Studio Code is this enable REPL smart. Send enable that.
1:59 I don't think it's on by default and I'll demonstrate what that does in just a second. Outside of that, you have a couple other options.
2:07 You want to activate the terminal environment, activate environment in the current terminal that you might have open.
2:12 You can enable those types of things with that checkbox.
2:14 You have launch arguments that you want to pass in when you run Python projects and files within Visual Studio Code.
2:22 Some auto complete options, extra pads for it to look at such as the Google app SDK, if you'd like. You can.
2:28 Point to that globally referenced library on your machine through this these settings.
2:34 Now, one other thing to note that makes the Python extension create this type of experience for us is it's using what's called a language server protocol.
2:43 The one by default that it comes bundled with is called pylance, which is why we're seeing that as another option here under the extensions.
2:49 If you don't like this one in particular, maybe it's not working to your expectations, but honestly, it works fine for me. You can change.
2:58 That you can install other language server providers. And choose that that as the one that you want for the Python extension to use.
3:06 So in this case, there's Python language server. you can use like Jedi for instance, or pylance.
3:13 And if you installed any other ones that might be out there, they would show up here. And that is the Python extension in a nutshell.
3:20 We're going to dive deeper into the overall experience that it's providing and how it enhances the development workflow and efficiency for us as Python developers in the next few weeks.


Talk Python's Mastodon Michael Kennedy's Mastodon