1.1 Install Python and PyCharm - Video Tutorials & Practice Problems
Video duration:
11m
Play a video:
<v ->The first thing we're gonna need to do</v> is actually get Python on our computer and also download an application to help us with writing our Python code. So, here's a list of downloads. The first one is it to install the latest Python version, the second one is to download the free community edition of PyCharm, the code editor we'll be using today and the last one is where you can find the lesson files. So, I'll go through each of them. For the first one, downloading Python, you can download whatever the latest Python version is, as of right now it's Python 3.7. Maybe in the future it'll be 3.8 or 3.9. So, you can click this, get the installer and run the installer. So, now if you are working on a Mac or a Linux computer, you're good, you can just like follow through with the installer instructions and skip ahead a couple minutes in this video to get to the PyCharm ones. If you're on Windows, there are unfortunately a couple extra steps that you should take in order to make this install a little bit smoother. So, if you're on Windows, and you come to this screen. The first thing that you'll wanna do is check this box that says Add Python whatever version to PATH, so this is how your computer will be able to know where to find Python. If you don't do this, then you're gonna have to, if you've already installed Python and you didn't do this, you can look up tutorials about how to add Python to your PATH environment variable. Next, you're gonna wanna choose this customize installation so that we can adjust where it's gonna be downloaded to. So, next you've got the Optional Features menu. This might look different depending on what Python version you have. You can just leave everything as is and click Next and then in the Advanced Options, ideally you'll want to install it for all users, so everyone on your computer can access Python and then also, customize the install location. What the ideal location is is just C:\ and then Python and the version number, so if you're on Python 3.7, then it would say Python37. Don't ask me why these are the defaults for Windows. I have no idea. So, these are the main things that you'll want to do for the Windows installation is add Python to PATH and save in this location. If you didn't do that, you can look at these instructions or you can find a tutorial on your own. I would recommend knowing how to Google for that. It would like Windows whatever XP 10, Vista, save Python to PATH environment variable. So, it's specific, it's related to what operating system you're on and it should, there should be a few different answers for how to do that. So, we can check that the right Python version has been downloaded and indeed been added or your path so you can get it, so this is for all operating systems, not just Windows and we can open up Terminal in Linux or Mac or Command Line on Windows. I'm just gonna search for it here. Terminal. And I get something that looks like this. So, this is a command line interface, so it's different from a graphical user interface and this is another way of interacting with your computer that's not in like a predefined way that someone built for you. This is just like giving it instructions, so I can test what Python version I have by saying python --version and then click Enter. And this will tell that I'm running Python 3.7.1. That's great. If you get a Python 2 number, you can check this, python2 --version, oh no, python3 --version 'cause some computers already have Python 2 installed and then ideally this should give you Python 3. If you got something that looked like this, imagine I put python3 in here, it says command not found, then your computer isn't able to locate where Python is, it was downloaded, so you'll have to then find where Python was added and add it to your path. So, the basic way of running Python would actually just be to in the command line run Python and you can start writing Python code here but it is not the easiest interface for people who are completely new to programming and who don't know how to use Terminal or Command Line, so we're going to download PyCharm to help us with running our code in a graphical user interface. So, the next download we have here is for JetBrains PyCharm. JetBrains is the company who creates this software. And you can go and download the Community edition and run the installer. So, lastly we wanna get the lesson files, so you can go to my GitHub repository and download the files. So, once we've downloaded those files, we can then open up PyCharm and you might have a few different popups come up asking you to do different options, you can just skip all those, just use the default configuration and then we can open, get the code and it should be this intro_to_python_livelessons_master and this is what it will look like. So, I will go over the interface very briefly before we start actually writing some code. So, once you've got that running, let's talk about what is PyCharm and integrated development environments or IDEs. So, we're using PyCharm because it's an application that handles Python out of the box, so just like Microsoft Word handles Word documents or Excel handles spreadsheet documents, PyCharm will handle Python code and other forms of code. It has syntax highlighting and error highlighting and autocomplete, so these are all features that will help you write Python code faster and know oh, I don't remember what the specific thing is called, so I'll use the autocomplete and search for it and it'll tell you oh, you have a syntax error here, so there's a lot less guesswork when you're writing Python code especially for beginners and then yeah, it's better for people who don't the command line. I would definitely recommend learning it at some point but that's not the purpose of this class. This class for Python. And then it's also full featured for professional Python developers. One of the reasons I like using it was because it has a lot of handy keyboard shortcuts that can be helpful once you get good and wanna write code faster. So, here's a list of keyboard shortcuts. There are some alternatives to using PyCharm, if you don't like it or it's too slow on your computer, you can look at all of these different options and there's a really good tutorial here about or yeah, opinion piece here about what the different options are and why you would wanna use one of those. Okay, in the left sidebar here, we have the folder structure for our project and we can see that we have a few different folders. These are the larger challenges. Here are some examples for future reference. We won't be looking at all of those today. And then these are the problems that we're gonna be working through to figure out the language. There's also this Scratches and Consoles which we'll be using to write some Scratch code. If I open up one of these, this is where the code will show up and where you'll type everything and you can see already some syntax highlighting where numbers are in blue and comments are in gray. So, you can differentiate things, you can see that there's syntax error highlighting and all that fun stuff. Now if you need to change some settings, you can go PyCharm Preferences on a Mac and on a PC it's File, Settings. And here you can change things like I prefer the dark theme, so I'm gonna apply that theme. This project intro-to-python, go to Project Interpreter and if you are having an error saying that it couldn't find or that your project wasn't configured with a Python version, then here's where you can change it. So, you would go here, you can choose what Python version you have but if you didn't have any here, you can say Add and then go to System Interpreter and find the Python version here that you're looking for. If it can't find it, it might mean that it's not on your path in which case you can click these three dots and manually find where Python is located. There are some other features here. If I wanted to change the font size, for example, I could change it here. I already have, that's why it's a little bit bigger and then finally, on the bottom, we have some options like the Python Console and this is another way of running Python. And we'll talk about that in the next lesson.