Will you be using Python on a Mac? Learn how to install Python 3 and Komodo Edit on a Mac, for use with the exercise files.
- [Instructor] To follow along with the exercises on a Mac, you'll need the latest version of Python 3, and I recommend the free version of Active State's Komodo Editor. Here's how to install these components on a Mac. And so first we're going to install Python. Now I've already downloaded the installer to my desktop, but you'll want to download it from here, and you'll want to make sure that you download the version that says Python 3. So this is Python 3.6.3. Whatever version you see will be later than this one and that's fine.
Do not download Python 2. Python 2 is probably already installed on your Mac, and it's used internally, and so you'll want to download Python 3 and that will run separately and in addition to the Python 2 and it won't cause any problems on your Mac. I've been doing it for years. So, I've already downloaded the installer here so I'm just going to minimize Chrome and I'm going to come over here to my desktop and I'm going to double click on the Python package here.
And we'll just press continue and continue and continue until we get the agree and press that. You'll notice I read all of that very carefully because that's important. And then I press install and type in my password and wait for it and once that's done, I press close. And Python is installed. It's as simple as that. We'll test it in a few minutes after we install Komodo. So I'm going to come back out here to my browser and here I've opened activestate.com/komodo-edit.
And there's two versions. There's actually several editions but there's two major versions of the Komodo Editor. One of them is called the Komodo IDE and you can tell that they want you to download that one because the button is bigger and it's red. And then there's the Komodo Edit which is free and you're going to want to download the Komodo Edit. You can look at the comparison. If you scroll down here, you can look at the comparison of the features of Komodo Edit and Komodo IDE and there's quite a lot of features that are in the IDE version that are not in the free version and if that's important to you, of course, you're welcome to pay for that and use that.
For my purposes and for following along, if you want your screen to look just like mine as you follow along, you'll want to use the Komodo Edit which is the free version. The Komodo IDE version, of course it has more features, and it costs about 300 to 400 US dollars for personal use. In this course, we're using the free version and we just click here on Komodo Edit and then on the big download button for Komodo Edit, whatever the latest version is is fine. It changes every year and I haven't seen a whole lot of big differences in them as they change.
Again, I've already downloaded this to my desktop and we'll just double-click on the DMG package. And just drag that over into applications. Wait for it to copy, and once that's copied, I can control click and eject the download folder. And you'll see here it is in my applications, Komodo Edit 11 and I'm just going to run that. And first you'll see this screen.
So this is the appearance and again, use the default or use whatever works for you. For my purposes, I'm going to try and make this as readable as possible and I'm going to select Cupertino and for now, I'm going to customize it a little bit later but for now that'll work and then next. And I leave all these defaults. I like indention to four characters. I don't like tabs. I just leave all of these as the defaults. And again, finish. Now this'll up the Komodo Editor.
I will maximize this if I hold down the option queue while I press this I get a plus instead of that so it doesn't do the full screen mode but it maximizes it. So I've modified this version to make the interface more readable for the purposes of this video. You should configure your own copy to your own preferences. You can come down here to preferences and you come over here to color scheme, you'll see you can open a color scheme editor. And it'll give you this little warning and you say yes. And the color scheme editor allows you to select a different theme and you can actually go in there and customize exactly how you want this to look.
And I recommend that you do that. I've made all the text really big and made it so that it works well in this video recording environment but that's not going to be what works best for you. Now before we go any further, we want to come back into here in preferences and there's several ways to open the preferences. You can use that button. You can come up here and select preferences from the Komodo menu. Or you can, as I usually do, just press command comma and that works on many, many Mac applications.
And there's a couple of things that we really need to do here. First of all, we need to come down here to internationalization and I'm going to explain this briefly. Python 3 is fully Unicode compliant and what that means is it uses the Unicode standard for its character sets and it makes it very international friendly for international languages. And so because Python is Unicode compliant, we want to make sure that our editor is using Unicode character sets.
So under default editor encoding, if it doesn't already say UTF8, you'll want to select UTF8. And then under language specific, you select this box and find Python and you want to do this for both Python and Python 3. It's important to do both of them because sometimes the editor thinks it's Python 2 when it's actually Python 3 so you need to do it for both of them. Select Python and change this to UTF8 and then select Python 3 and change that to UTF8 and then make sure that it takes because occasionally it doesn't and that seems to be fine.
And then you'll want to select okay. And this is really important because so in what we're doing, we'll use Unicode characters. Now we're going to open our exercise file. So we come over here to left pane and select the gear and open directory. And I'm going to come out here to desktop and select exercise files and say open. And that'll open the exercise files over here. We don't really need this projects pane at this time.
And now, we're going to open the right side pane. And this may be in a different place here but you want to open the right side pane and again, your pane may look different. Your toolbox may look different. You'll want this to be, the toolbox will show there, and I'm going to control click in an empty space and say add new command. And this is going to give us our command that we're going to use for running our scripts.
This is the difference between the editor and the IDE version. The IDE version has ways to run scripts already. We have to create one but it's really, really easy to do here and we only have to do it once anyway. So right here in the command box, we're going to type, and it's very important that the spelling and the capitalization and everything is exact so be very careful and I'm going to do this very slowly here. ENV and a space and then all caps LANG which is short for language but just the letters LANG and then the equals sign and then again we're in lowercase EN which is short for English, underscore, and then capital US and a period and then all caps UTF dash 8.
And again what this does is it makes Komodo work properly with Unicode characters. And then we're going to put in a space and in quote marks, and it's hard for you to see the quote marks 'cause this text is so small on this screen but that's a double quote, percent, capital F, and a close quote. And again those are double quotes and that's a percent sign. So this is everything that needs to go in this box and it needs to go exactly like this, and all the spelling and capitalization and punctuation is important and then up here, I'm just going to select this and make this say run dash R like that.
And that's going to be the title of this command. Now before we're done here, we need to come over to advanced options and in the start in box, you're going to select this little arrow here and select directory path of file and it'll put a percent D in there and that's exactly what you want to be there. And then over to the key binding tab, we're going to create a key binding so that we can call this up just by pressing a key press. And the new key sequence is shift, command, R.
So you're going to hold down the shift key and the command key which is the one with the little clover leaf on it and press R. And in the box, it'll type meta shift R like that. And then you have to press the add button or this doesn't work and now it should say it under current key sequence. So under command, we have our command and it looks exactly like that. Under advanced options, we have the percent D there. And under key binding, we have that meta shift R. If all that's correct, you can press the okay button and you'll see over here, it shows up in our sidebar, it says run dash R and we'll test that in a minute.
But for now, we're just going to close that right pane, and we're going to come over here to our chapter 1 files and open that up and double click on hello dash version. And I'm going to press shift command R which will run it and we'll see down here in the command output at the bottom it says, this is Python version 3.6.3. So this is testing everything. We've installed Python correctly. We've installed Komodo. We've set it up to run our scripts, and now our computer is completely set up to run Python scripts in Komodo Edit.
- Python anatomy
- Types and values
- Conditionals and operators
- Building loops
- Defining functions
- Python data structures: lists, tuples, sets, and more
- Creating classes
- Handling exceptions
- Working with strings
- File input/output (I/O)
- Creating modules
- Integrating a database with Python db-api