Setup · 26:23
Installing Python
Course overview and installing Python on Windows and Mac.
- Learn Python for AI apps.
- Install Python and VS Code.
- Run your first script.
| Step | Tool |
|---|---|
| Language | Python |
| Editor | VS Code |
| Run | Terminal |
Do this in your own tools, step by step. Ticks are saved on this device.
Editor?
VS Code.
First script?
print().
0:00 So whether you want to build your own AI apps, get into data science, or simply become more valuable in your career, this is one of the most in demand skills you can learn right now. And now there are already a ton of learned Python tutorials and courses out there, right? You're probably wondering which one should I follow and why should I watch this video? Well, most of the videos out there actually waste your time on a lot of stuff that you actually don't need to know if you want to use Python specifically for AI.
0:22 So, this video is different. We'll start from the basics and I'll make sure to explain everything step by step so you can follow along. Then, I'll teach you all the core concepts you need to understand in order to learn Python fast. We'll build up in complexity, work with data, and create reports. And as a final exercise, you're going to build your own AI chat assistant that can chat with your data. My name is Dave Ealar. I'm the founder of Datal Lumina, an AI development company where we built custom AI solutions for clients across many industries now.
0:45 I've been using Python almost every single day for over a decade, and I already taught this language to more than 35,000 students worldwide. So, if you're looking to learn Python from a professor who only teaches, this is not the course for you. Everything that we'll be doing in this course is practical, battle tested, and it's based on real work in the AI field. The stuff companies and clients are paying for right now. And look, it doesn't matter what your background is.
1:08 You're never too young, too old, or too late to start. If you can follow simple explanations and have a bit of curiosity, that's important. You can do this. So, grab a coffee and take out your notes. This is Python for AAI, the course I wish I had when I started. Let's dive in. All right, so let's get started. I am super excited to go through this entire course with you and to teach you everything that you need to know about Python to build AI applications.
1:30 Before getting started and installing Python, let me give you a quick overview in 30 seconds how to get the most out of this course. What you are looking at right now is the handbook which I will make available for you link in the description. It's hosted under python.dataluminina.com. All of the other information, links, codelocks that you need will be in here. So use that to your advantage. Now, whenever I go too fast, you can go back here, find more information.
1:53 And whenever you feel like I'm going too slow, use the chapters below this video to skip ahead or use the speed controls below this video to increase the speed of the video. And now, what's going to make this course different from a lot of other Python courses out there beyond just the focus on AI. In the beginning, we're going to spend a lot of time on setting up a professional work environment for you. You see, most Python tutorials and courses go through the Python setup and then they immediately jump into writing out isolated Python code examples.
2:38 But what I found over the years teaching thousands of students this language is that in the beginning, writing the code itself isn't the hardest. And especially nowadays with AI, you can literally ask JPT to come up with anything and you can plug it into your code editor. What you need to focus on in the beginning is having a solid understanding of the tools you use, how to set up your environment, how to manage package and dependencies and how you can create projects so that whenever you go out in the real world beyond this course and you want to build something or follow a course or tutorial, you know exactly what it is that you need to do and you'll have a professional coding setup exactly the same as what I am using right now and what you would actually use when you get a job and work with Python in the real world.
3:02 So just know that we're going to spend quite some time there in the beginning. That's the whole getting started chapter and it's there in the beginning for a reason. You don't want to skip this if you're not familiar with these concepts. So, we'll get into all of the installations, setups, and configurations that you need in order to work professionally with Python. Then, in the Python basics, that's where we actually get into the programming language. And now, even if you already have some coding skills or you're coming from a different programming language, I still highly recommend to go through this entire getting started chapter with me because I will show you the exact setup that I am using right now so that if you follow through with the course, everything that you see will be exactly the same on my screen as well as on your screen.
3:45 All right, so let's get started. The first thing that we are going to do is install Python on your machine. So following the handbook, I am here in the section installing Python to get it up and running on your computer. So, I'm first going to walk through the Windows setup. If you're on Mac, you can use the timestamps below to skip ahead. So, the first thing that you need to do is you can go to python.org/d downloads or follow the link over here.
4:08 Then you will find this page where you can simply click on download python. And then once that's uh completely done, you can doubleclick on it to start the installer. Now, here is a very important thing. When you go through the installer, you should check the following box. When it asks, should you add Python to the path? You should check mark that. It will look somewhat like this. So, you can see it over here. Let me add a little bit smaller for you.
4:31 Now, this is an older version of Python, but the setup will look something like this. And you should add Python to your path. Then, you can just follow through with the installer. Do not customize anything unless you know what you're doing. All right. And that's it for the quick installation. Super easy to follow. So now next in this video I will show you how to do this on Mac but you're on Windows. So make sure to skip to the next chapter where we're going to install your code editor.
4:54 All right. So now I'll show you how you can install Python if you are on Mac. And the first thing that we need to check here is check whether Python is maybe already installed on your system because for a lot of Mac systems this is already the case. So what we are going to do is we're going to open up the terminal. And don't worry if you've never used the terminal. We just use it to type in a command and it's not that scary.
5:16 So what we can do is we can open up Spotlight. And you can do that by hitting command and spacebar. Then this will show up and you can type in terminal. So if I open that up, you'll see this console coming up over here. This is a terminal where we can run commands. And all you need to do right now is come over here to the documentation and you should type in Python 3 space- version. So you can type it out or you can copy paste it like I do over here.
5:39 Come to the terminal and then I'm going to paste that in with command V. And what I can now do is I can hit enter. Now you can see on my Mac it is already installed because it's showing me a Python version meaning it's installed. If you also see a version over here that also means Python is installed. If you get an error over here mentioning like look Python is not available or it's not recognized then you still need to install Python and you can continue with the rest of the instructions in here.
6:02 So in case you do need to install it you can scroll down over here on this install Mac page and you can go to python.org/d downloads which we have open over here. You can click the big download button. It doesn't matter if it's a different version. If you watch this in the future, it will be different. So, you click the download button and then over here it will start to download. So, then while you wait for that to finish, you can go to your download folders.
6:24 Simply doubleclick on it and install Python like any other app. All right. Congratulations on installing Python on your machine. Now, the next step is to install an application that actually allows us to work with the Python programming language. So, we are going to install my favorite code editor to work with the Python programming language, and that is Visual Studio Code. And that is really all you need. I've been using this application for the past 5 years already.
6:48 I love it. It's completely free. It's super extensible, and it's really it got it's got everything that you need to professionally work with the Python programming language. And nowadays, there are, of course, a lot of AI assisted code editors out there. Cursor being one of the most popular ones right now. The good thing is that everything that you do in setup within Visual Studio Code can also be done exactly the same and imported within Cursor because cursor is built on top of VS Code.
7:11 So let's get into how to set up Visual Studio Code. So I come over here to the install VS Code tab and again depending on whether you're on Windows or Mac OS, it's a little bit different, but you can just go to the website and this big download button over here, it will be dynamic for the operating system that you're that you're on. So for me, it will say Mac. for you. If you're on Windows, it will say Windows.
7:34 So again, download it. It will go to your download folder. Click on it and follow the installation in there. One more time. It's important that you add it to your path on Windows. And then you just click install, finish when done. Process is exactly the same for Mac OS. You can keep it in your doc. There might be some security questions that pop up where you need to give it permission. So just follow that. It's completely safe.
7:57 The application is for Microsoft. And then we can go and verify the installation. So what we can do right now is we're going to open it. And there we go. So this is the first screen that I see right now with versions updates, a welcome screen, and now since Visual Studio Code is so extensible and it it can work with a lot of programming languages out of the box, there's not much there. So, what we're going to do right now is I'm going to share my exact setup with all the extensions and settings that I use to work on all of my Python projects that I've been doing for the past 5 years.
8:45 This is really a professionalgrade environment that we're going to set up. And this is so so crucial to spend a little bit of time here to understand this tool because what you'll find on this journey of learning Python is that actually the act of writing code, writing out the like line by line sentences and the characters like you will quickly get a hang of that and AI can work really well with that. AI can help you as well, but you need to be able to know where to find it, how to set it up, how to create a new project, how to add new things to it, how to run code, how to debug code.
9:11 So, that's also going to be a a big difference between a lot of the other Python tutorials and courses that you'll find out there. And I know that in the beginning when I was learning Python, this was so annoying to me where always, yeah, I would get it on like a single file. I could follow a tutorial, but then when I was on my own project, things looked different and I just didn't have the full system and it just didn't understand the full process.
9:33 So that's what we're going to spend some time on right now. Okay. And the first thing that we're going to do is we're going to install the Python extension. So I can click on the link over here to see where this is going. But we can also do this directly from Visual Studio Code. So what I'm going to do is we're going to the extensions tab and then we're going to search for Python. So let me walk you through that.
9:57 Here is Visual Studio Code completely empty. You can see the extensions over here. So, it's this little icon. There's also a keyboard shortcut to it. And you can see it's already recommending something to me. Python over here. But in case this is not there for you, you can type in Python. And then it should show you exactly what's over here. Python. It should be from Microsoft. You see the blue check mark over here. You can click on it or directly install here or over here.
10:21 So what this is going to do, this is going to behind the scenes install the Python extension so that when we work with Python files, our editor, our code editor can recognize it. So this is an essential extension that we need. Okay, so that was the Python extension and now we're going to change a quick setting. We're going to use this later. Don't worry about it for now. All you need to do is go to the settings of Visual Studio Code and you should copy paste this or search for this.
10:44 So Python terminal execute in file directory. This is really useful for later down the line. So I can come in here. I go to settings. And then you can search for this. And you want to make sure that this is checked on a fresh new install. It's like this. And you want to click this. And that's it. You can just X out of it. It will automatically save. So this will make sure that later when we're going to execute Python files, the editor will execute the file from the directory instead of the workspace route.
11:06 So when we're going to reference files, it will be a lot easier. All right. Then next, there are two more extensions that I recommend to install. The first one is pylance and the other one is Jupiter. So let's start with P lens first. We do exactly the same process. We come in here. We search for pilance. We see it pop up over here also from Microsoft. And you can see it's it's actually already installed by installing Python.
11:28 But you can double check this. So make sure that if you go to Pilance it it if it says install you should click it. And then we go to Jupiter which is something we are going to heavily use throughout this course but I will show that later. For now, we can just click install and then we should be good. This takes a couple of seconds. Now, coming back to the instructions over here. What we're going to do right now is we're going to customize the code editor.
11:53 And this is completely optional. This is not going to change anything about how the code editor works, but I like to set up uh my environment in a specific way. So, for the past years, I've been using this uh theme and I really like it, the Atom one dark. So, let me show you how to install that and what that looks like. And you can also search for other teams that you like. So, this is really just like the coloring, the fonts.
12:15 You'll see it in a bit. So, I can search for Atom one dark team. Hit install. Trust publisher and install. There we go. And it automatically right now it already sets the coloring. You saw it, right? So, yeah, you can see right over here it now asked, do you want dark modern or Adam one dark? So, I set this over here. You can also click on set the color team. So that's now installed. You can also at any point come all the way to the bottom over here where you see the little gear icon and you can see themes over here and there you can see the color theme and the file icon.
13:01 So if I click on this the color theme you can see everything that is currently installed. So if you for example let's click on the Kimi dark you can see this is a very different look to what we had right. So this is for you a way to go through it and to pick a theme that you like. All right. Now, there's one more setting, the three indentation, but we'll actually get back to that in a couple of minutes because then I can actually show you what it does.
13:24 So, for now, we are going to go to the next section, and that is creating projects. One of the most important things in the beginning to fully understand because this is really the point where look, you see examples online, you see me go through this tutorial, but now you're in the real world and you have an idea, you want to try some. Where do you start? Right? We have Python installed. We have a code editor, but how does it work?
13:47 How where are the projects? So, let's set that up right now. So, what I recommend you to do is creating a folder somewhere on your computer. Doesn't matter if it's in your documents, in your home directory, any type of place where we are going to store all of our Python projects. So, for the sake of demonstration, I'm going to create one on our data luminina drive over here. So, I'm going to call it Python projects. All right.
14:10 And now what I want you to do next is inside this folder. So this will be the master folder. And in here we can do we can create all kinds of folders for all the projects. So first we're going to create a folder for this course and we're going to call it Python for AI. But whenever you have another ID you want to try something else I invite you to do that in that same folder and follow a similar structure and a similar setup so that you work very organized and you always know where all of your Python projects are.
14:34 Now for the main folder, it doesn't really matter what type of naming convention you use, whether you use capital letters or not. But for the project folders itself, I recommend to use all lowercase and dashes. And why this is the case, this is actually called kebab case. And this is going to match how projects are going to appear on GitHub. This is something we'll cover later. But this is just a best practice that I always do and I recommend you to do as well.
14:57 So what it then looks like if I come in here Python projects I'm going to create a new folder and I'm going to plug in Python for AI all lowerase and dashes using the kebab case. So now we have that created. What we can do right now is now from Visual Studio Code we can open up this folder. So let me come back over here. This is what your Visual Studio Code should look like right now.
15:20 If you go over here to the explorer. So before we were installing all of the extensions. Now we can go to the explorer and you can see this is empty. You have not opened a folder yet. So we can click on that click on open a folder and then we go to the place where we just created our Python projects and then Python 4AI. So depending whether you're on Mac, Windows is a little bit different but make sure to navigate through the explorer or the finder to this folder.
15:42 And then what you can do right here is you can click on open. And now what you can see is now this folder is opening. And the first time you do this, Visual Studio Code will ask, do you trust the outers of this file? We created it. So yes, should be good. Okay. So now we have this empty screen over here. And now there's one more important step that you need to do for every project that a lot of beginners forget.
16:07 And that is creating a workspace in Visual Studio Code. Because what we do right now, we open up a folder and now we need to save that folder and everything in there as a workspace. A workspace is Visual Studios Code way of defining projects. And why we want to do that is in this way we create a single file that we can doubleclick it will open and everything will be there. So when you're working on something, you hit X, you shut down your computer, you restart it, you can doubleclick on one file and everything will be there exactly how you left it.
16:54 That's what the workspace is about. It's like a bookmark. It remembers everything. So now what you want to do is you want to save the workspace. So within Visual Studio Code, we go over here, we go to file and then over here you should see save workspace as. So we can click on this and it will by default open up the the explorer or the finder in the same folder that you are currently in and it will also give it a default name.
17:17 It will say save as Python4i.code test-workspace. This is the VS code file extension that you need. So if you set it up like this, there's no need to change anything about this. So this folder is already selected and I can just hit save. So what you now see is you should now see this workspace folder show up over here and we can also confirm that by going over to the finder or explorer and in the folder we now see the following workspace.
17:41 Right. So now we can test this if this works correctly because what we can do is we can close out of video code. So now it's gone. We can even quit it. And now we can go to the finder Python projects Python for AAI and then we double click it. And there we go. We are back in our folder now with the workspace file in here. All right. So now with the workspace set up, it's time to create your first Python file.
18:05 What we're going to do is we're going to create a new file and call it hello.py. So let's come back to Visual Studio Code. And what we can do over here is we can either use the buttons over here. So you can click a new file over here, but I can also rightclick and say new file. So let's come in here and let's type in hello.py. Now please be mindful of the extension that you have over here.
18:05 So right now you can see that here if I type in hello.py you will see that Visual Studio Code displays the Python logo over here. So it recognizes that this is a Python file. Now this is very important. It doesn't matter what name you give it in here. That doesn't matter. But the extension should be.py if you want to work with Python files. Now you can also uh for example do a txt to do a text file or you can do a markdown file or you could do a JavaScript file.
18:52 Visual Studio Code is flexible enough to understand that based on the file extension. So for now do hello.py and hit enter. Now we can open up this file in our editor and see it pop up over here. So on the left you have your files and now you can see the file over here hello.py. So this is where we can now actually start to write Python code. And the first thing that I want you to do is write a simple print statement similar to how we did that in the terminal at the beginning of this tutorial.
19:15 Right? Remember? So we do print and then we do an opening bracket and Visual Studio Code will automatically just by hitting the opening bracket will already create the closing bracket. You can also see how we have different colors in there. This is all possible because of the Python extension and pyance that we have installed. Then we can do double quotes and we type in hello world and an exclamation mark. So we now have pretty much the most basic Python script that you can think of only with a simple print statement.
19:37 So let's actually see how we can run this because in the terminal we would type this out and we would hit enter right but if I hit enter right now I will simply go to the next line similar to what you have in word or any other text setter and I can write more print statements. So now let's cover how we can run this file over here. And before running your Python file, there's one thing that you should always do at the beginning of every project.
19:59 And this is also one of those things that in the beginning you often forget it. You just have to double check it. But don't worry throughout this course. We will cover it lots of times so you'll remember. And that is setting the correct Python installation because we have installed Python on our machine. But we also need to tell Visual Studio Code which Python version to use. Now out of the box generally nine out of 10 times this in right now automatically goes correct because you can see right now here in the bottom screen you can see 3.13.5.
20:45 So right now you can see it is using this Python installation on my machine. If I click on this you can see I have more Python installations over here. If you use virtual environments, something we will cover later in this program, which is a core skill that you need to understand, you'll end up with multiple Python versions that you can select. So, for now, it's important that we select the default one. If you've just installed Python, there's likely only just one version here, but make sure that you refer to the Python installation that you installed at the beginning of this session.
21:10 So I click on this and now Visual Studio Code knows okay if I want to run this this Python file here is the installation that I need to use. And now in order to actually run the Python file and execute the code what you need to do is you go to the top right corner over here and click on the play button. So what this will do is this will open up the terminal window within Visual Studio Code and it will point to the file on our system.
21:32 So you can see the full pot over here and then it will use your Python installation to run this. And you can now see that when we run this, you first see the line over here. Where is the Python file located? And then you can see hello world over here. Now I can simply close this out. I can also click in here and I can do run Python file in dedicated terminal. You'll find that this is exactly the same.
21:54 It create it will create a new terminal session. The easiest way for now is just to remember when I want to run the script, I can click on this. And now what is actually going on here behind the scenes is something I want to explain. Because when we click on this play button, what our editor does for us, it executes a command. But if we were to not use an editor like this and simply run this file via the terminal, how would we do it?
22:17 So let's show uh let's have a look at what what is actually happening. So right now we can also execute this file by saying look we want to use Python and then we point to our hello.py pi file and we simply run that. So you can see that right now this is also executing this file and it's printing this hello world in here. So if we now close this out and one more time click on this.
22:42 So let's have a look at what's going on here in the terminal because it's a lot of information but all that there is to it is first of all it says look we're in this current folder. So we go within our terminal, we go into this folder where we were currently at. Then we point to the specific Python location and before in the example I just did Python, right? But in the terminal when we do this via editor, it's explicit.
23:07 So it completely says, look, we're using this version of Python. And then we point to the Python path. So here you can see even though let's see, it's cut off a little bit, but you can see it's pointing to this hello.py file over here. So that is just what you should know about what's going on behind the scenes when you click on that play button because you could also do this within the terminal without needing Visual Studio Code and you can do it by simply checking look I have the Python command this is available I can do that and I can quit out of that and I can use that Python command to reference certain files you need to write out the entire file path and now because we're in this folder already we can execute it.
23:29 So as you are learning the Python programming language, this is really a fundamental skill and an idea that you need to understand. But luckily when we are using an editor, we can just hit the play button. So we don't have to do it, but we need to understand what's going on behind the scenes. There's also a default keyboard shortcut that you can use and that's Ctrl F5 or CMD F5 on Mac. I actually like to change this.
23:54 So let's do that right now to see. You can set it to anything you want. So if I come over here to the settings and then go to keyart keyboard shortcuts and then type in run python you can find the python run python file over here and then under the key binding column if I click in here I can now plug in any keyboard combination that I want. I actually like to do cmd enter and then overwrite that.
24:16 There are already commands in Visual Studio Code that have that as well but I find if that you have it like this I can simply now hit cmd enter or control enter if you're on Windows and I can now run this. If this is causing any issues for you or you want another shortcut, feel free to change it or just use the play button over here. One more thing that you should also know right now is that if you click on this play button or run the code, this terminal will open up over here.
24:38 And this terminal that we're seeing right here is exactly the same as the terminal we used before, right? So here on Mac you have the terminal, on Windows you have the Windows terminal. So I can do here python- version and it will show the Python version that I'm using. In a similar way, I can do that here as well. So I can do python- version and I can also run that here. So that's something important to keep in mind.
25:01 Whenever we're working with Python code over here and we send it to the terminal, all the things that we can do in a regular terminal, we can also do that here in here right from Visual Studio Code. So we don't have to leave it when later we have to install certain things. So generally, especially in the beginning, you actually don't have to deal a lot with the terminal. you just close it, delete it and then whenever we need to run something, it will open and then occasionally we need to install some things or tweak some settings and that's where the terminal will come into play.
25:48 And whenever the terminal is gone, so for example, you X out of it or you lose it. You can also go always go to the top uh menu bar, click on terminal and then for example do new terminal. Now it will show up again. There's also a default command. It's either cmd or controll J. So I can hit that and that will just like it will not close it but it will hide it. So now if I come in here and I do python d- version one more time I show it I do uh command j I can hide it and then here you see I have the exact same terminal session still open.
26:11 All right so now as an exercise you can give this a try and experiment with some different print statements just to get a feel for what it's like writing code hitting command or control enter and
Get the other 14 chapters, the exam and your certificate for LinkedIn, plus all 700+ AI courses.