Setting up a Python Development Environment in Atom

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there how's it going everybody in this video I'd like to walk through how to set up a Python development environment in Adam now Adam is a text editor that is becoming a popular alternative to editors like sublime text now I've done a video on how to set up a Python development environment in sublime text but a lot of people are starting to give Adam a try so I wanted to put together a video on this as well so that people can get their Python environment set up easily now there are some good reasons that Adam is becoming popular so first of all it is completely free now sublime text is free to evaluate for an unlimited amount of time but you'll get pop-ups asking you to purchase the full version every now and then so Adam being completely free is definitely appealing to most people and also Adam has a lot of support it was developed by the people at github and it comes installed with a package manager and makes it easy to install packages right out of the box now so blind text has improved that in process and some of its later updates but there's still an initial step there that needs to take place before you can begin installing packages and Adam doesn't have that problem and we'll see some other differences as we walk through this setup process now if you never use sublime text before then you can just ignore the comparison it's got to make throughout this video the only reason I bring those differences up is because these editors are very similar and they share a lot of the same user base and those people might find it useful to have those differences pointed out ok so let's go ahead and get started so I have the Adam download page pulled up here now I'm on my Mac so it defaults to the Mac download but you should have a download link for your operating system here so I'm going to go ahead and download that and I'm going to go ahead and skip to where this is finished downloading and once that's finished downloading then we can unzip that and on a Mac we just have to drag this app to our Applications folder if you're on another operating system then you might have to go through a quick installation ok so now let's open up our fresh installation of Adam and now I'm just going to go ahead and maximize this ok so when we first open Adam it's going to pop up with some welcome information here so on the right we have this welcome to guide with some documentation to keyboard shortcuts and things like that I'm going to go ahead and just close that down and close this link now on this welcome screen here I'm going to uncheck this show welcome guide when opening Adam and now I'm going to close that now this telemetry consent I'm just going to click no here for now but you can do whatever you want here it's just to help them improve Adam you can anonymously send information and stats and things like that just so we have something to work with I have a test Python module here then I'm just going to go ahead and dump in to Adam go ahead and open that up now this is a sample class that I use from my object-oriented series if you don't understand what the code is doing then you don't have to worry about it I just wanted something that we could work with and also something with classes and functions so that we can see the differences between the different color schemes and I'm going to make this font a little bigger here so that we can see everything now if you watch my sublime text walk through and at this point we were actually able to go ahead and run our Python code now in Adam we can't quite do this yet we have to first install a package so that we can run these scripts so let's install that first package so that we can add this functionality so to install package let's open up our Preferences page and on a Mac that is under Adam and preferences now on Windows I think that might be under file preferences now the Adam preferences and settings have this nice layout we don't have to use japes on configuration files or anything like that so it's a nice little interface that's pretty intuitive so to install our package we can just click on install down here at the bottom now the package that we want to search for is called script and if we search for that and we can see that the top result is what we are looking for now there's also a nice feature here that shows the total number of downloads which gives you a good idea of how popular a package is so just click on install to install that package and once that package is finished installing then you can click on these settings to view the settings for that package now within these settings this is where we can configure our packages how we like but this is also where we can view the readme files and get suggestions for how to properly use the package now if we scroll down to the bottom here then we to see a section on keyboard shortcuts so now with this package installed we should be able to run our Python scripts within Adam the keyboard shortcuts here are for each operating system so I can see to run this on the Mac its command I and on Linux and windows it's shift control B so I'm going to move over here to this test module and run this with the Mac command keyboard shortcut now the output that we got here for this script is a little small you might not be able to read this but basically when we printed out our executable path I got the default path to the Python on my machine and that version is Python 3.5 and then it also ran the other information here within this script as well now that default path on your machine may be may be different than the default path on my machine now if you want to run at different versions of Python or run Python from a virtual environment here in Adam then there's something different that we need to set up and I'll show you how to do that later in this video but for now let's go ahead and install the rest of the packages and get this customized a bit so first of all let's go ahead and install a different color scheme now the color scheme I like to use is the same one that I like to use in sublime text and it is called pre-dawn so to install this I'm going to go back here to the preferences and I'm going to click on install and instead of packages over here I'm instead going to click on themes to search for themes and now that we're searching for themes I'm going to search for pre-dawn now this part is a little different than sublime text and sublime and we installed the entire theme but in Adam these are broken up between UIs and the syntax I actually like the default UI that comes with Adam so I'm just going to install the syntax coloring so over here I'm going to click install on the pre Don syntax so now that's installed but it's not activated yet so to activate this then we can click up here on themes and under the syntax theme then now we have this pre-dawn option so I'm going to go ahead and select that and now if we go back to our test module then we can see that the look of this has been stated and this is just a personal preference I'd recommend you try different themes and color schemes to see what you like but if you watched many of my videos and you'll probably notice that this is the one that I personally use so now that we have our color scheme in place now let me show you a few of the default settings that I personally like to change so within our settings here now let's go up here to editor and within editor we can choose our font family so the font that I use is source code Pro and that is a font that is available for free on Google font and I'll leave a link to that in the description section below now the font size I usually like to have set to 20 and I know that that's large but that's just because I do these videos and want everyone to be able to see you'll likely choose something much smaller there now if we scroll down here a bit now there's one setting that I like here called scroll past the end now if I go to my test module without that selected now you can see when I scroll down to the bottom then I can't scroll anymore once we hit the end of the file and that kind of annoys me so I like to set that skull press scroll pass in option and now when I go back to my module then you can see that we can scroll past the end of this file and also whenever I am programming in Python I like to have my tab length set to four spaces and by default in Adam that is set to two so I'm going to go ahead and change that okay and that does it for the editor settings now one other thing I like to disable an Adam is the default Auto completing so for example if I go to my test module down here at the bottom and I was to type in you know employee two equals e then you see that it's popping up this near these autocompletes as I'm typing and a lot of the times I don't find these pop ups that useful so I'd personally rather just disable them and now to do this we can go back to our settings and then we need to select our packages now you can see here are some core packages that came installed with Adam and if I scroll down here now you can see a short description of what each of these do now the one that I want to disable is this autocomplete plus and also autocomplete snippet so I'll disable both of those now if I go back to my test module then you can see it's no longer trying to autocomplete those now if you are someone who likes that Auto completing capability then the suggestions for Python code are much more Python friendly if you install the autocomplete Python package so let's go over to our settings and let's click on install and now we want to select packages over here instead of themes now I'm going to search for auto complete Python now I don't personally use this but I'll just go ahead and install this really quick just to show you how this looks now when this finishes installing it's going to ask if you want to use kite or a local engine now kite is something that goes out onto the Internet and finds documentation and things like that now I think it sounds really interesting but some of the things that I work on it my full-time job aren't allowed to be sent over the cloud so I usually choose to use the local engine instead but if you think that clout or that type sounds interesting then you're more than welcome to give that a try ok so once we've selected that local engine now if we're back here on our test module now if I type in you can see that it's trying to autocomplete as I type and these are more Python specific so if I come back and just type in you know this e then I'm assuming that these bees mean built-in I'm not entirely sure but you can see that we have some more Python specific auto-completion there so that is a popular Python package but like I said I don't personally like the autocomplete pop-ups so I'm going to go over here and just disable the auto complete package that I just installed ok so let's install a few more packages that I like to use within atom so some of these aren't specifically Python related but I like the functionality that they add so if I click on install here we're already at this installation page make sure that we're on packages now one package that I like a lot is file icons now before I install this if you look here at our Python file in this tree view over here it's just a simple file icon and this package will make those look a little better and it also is a little bit more descriptive of what the file actually is so you can see that the top result here has over two million downloads so it's a pretty popular download so let's go ahead and install that and once that's installed now if we look over here to our Python file now we can see that the icon is now a nice colored Python icon right beside the file name and if you work on a large project with a lot of different file types and I think this package not only makes that tree look better but also helps you find files more quickly ok so another package that I like to install is one called mini matte so let's go ahead and search for that and this top one is the one that we want here so let's go ahead and install that ok so once that's finished downloading if we switch over here to our module then we'll see now that in to the far right over here we have this general overview of what the file looks like and also where we are in this file now this isn't so useful with such a small sample module but if we had thousands of lines of code then this gives you a better idea of where you are in those scripts ok now let's add a package that's more focused on Python programming so this package is called python auto pep 8 so let's go ahead and search for that it is python auto f8 now I like this package because it keeps everything nice and consistent so let's go ahead and install this and we'll take a look at what it does now there are a few other pet bait packages that have more downloads than this one but I found this one to be the easiest to set up and use so now let's go ahead and go into the settings of this package that we just installed so within the settings here if we scroll down to the bottom then we'll see a very short readme file and it says to make sure that we have auto pep eight installed by using the pip install Auto pep eight command so I'm going to go ahead and copy this and if you don't have that Auto pet bait installed then we may need to install this from the command line using hip so actually I just installed that or copied that but I'm just going to type it out so pip install Auto pep eight now if you've never used pit before it's very simple to use I do have a separate video on how to use pip if you need a walkthrough but for now I'm just going to go ahead and do that tip install okay so now that is installed now let's go back to the module and see if that takes effect so let's make some changes here and add some extra spaces that aren't really Pepe compliant and when I save this it should Auto format okay so I saved it and it didn't auto format I think sometimes whenever we install different packages we might need to restart atom for those changes to take effect so I'm going to go ahead and quit out of atom and then open that back up okay so now let's see if I make a change and save it okay so that still didn't work let's open up the settings here okay so there is a check here for format unsafe so I forgot to check that so that was probably the problem so now let's go back to the module again now with that format on saved checked now if we save this okay so now after I save that it you know Auto formatted so let me do that again and save it and you can see that everything jumps back up I have the proper pet bait spacing now having that Auto formatting on save is especially nice when working with a team because you don't want a lot of the get differences to be differences in line spacing and things like that so using this helps a lot in those scenarios okay so the last package that we're going to install here is a linter that will point out any of our mistakes so I'm going to go back over here to the settings and install packages and the lentor that I like is a package called linter flake 8 so it's search for that okay so this is the package that we're looking for here at the top so I'm going to go ahead and install that and it also has to install a dependency and called winter so it installed that when we installed the flake 8 winter okay so just like our Auto pep 8 package let's open these settings and let's scroll down here to the readme file and we can see that it has installation instructions as well and just like with the auto pep 8 we need to pip install this flake 8 if we don't have it installed already so I'm going to pull up my terminal and just like I did with the auto Pepe I'm going to do a pip install and that is flake 8 ok so now without restarting atom here let's open up our python module and let's type in some errors that our Lennard catch so down here at the bottom let's make a for loop here and let's accidentally so I'll say for num in and I'll just make a list of 1 2 3 4 and I'm going to accidentally leave off the colon here at the end of this for loop and within this for loop I'll do a print and instead of printing num I'm just going to print in so now if we save this now we have two errors here one says a syntax error at line 26 this is unexpected indentation so now we can actually click on these lines here where it's showing the air and after looking at this line that's telling us where the syntax is bad we look at this for a little bit and we'll probably realize that the colon is missing here so let's put that code in and save that and now after I save that we can see that we have a mark here that says unidentified name in at line 27 so once it points out out to us then we know that that should be num instead of in on also looks like it gave us that syntax error - because I forgot to remove that line from earlier when I was showing the autocomplete ok and after we remove all those errors than all of those linter warnings go away and it's nice having something like that watching in the background because we all make dumb mistakes like that and it's nice to have something that points those out okay so that was the last package that I wanted to show you but one thing that I mentioned before was that I'd like to go over how to run different versions of Python or how to point to a virtual environment so if you watched my sublime text installation video and this is basically the equivalent of their build systems so that very first package that we installed to run our Python code that was called script if we want to run our Python code using that then like I said before we can hit command-i to run that but we can also hit command shift P to bring up our command palette and then we can type in script which is the name of that package now you can see here that this gives us the option to run that's what we've already seen before and then the keyboard shortcut over here is command I but there's also some additional options here and we can see here that one of these is run options so I'm going to go ahead and click on that and then it pops up these different options that we can use when running the script now the one that I want to change here is this command so this command here we can plug in the path to whichever Python that we want to use so for example I know that my path to Python 2 7 is in user bin Python 2 7 so let's say that I wanted to run our script with this Python 2 7 version so we can either just run that or we can save this as a profile now we're going to want to save this as a profile because it's something that we're going to want to use over and over without having to type in that path every time so I'm going to save that as a profile and I'm just going to call that Python 2 7 and now that python 2 7 pops up and I can run the script with that and now if we look at our output down here now sorry again that this text is small but I'm not sure if there's a way that I can enlarge this or not but I'll go ahead and just read to you what it popped out here but when we print our Cystic you table turning out the path to that Python to seven and when I print out the system now it's printing out 2.7 down here so it is using that Python 2 7 version now the script doesn't default to any of those profiles so if I just run the script regularly so I just ran it again and now down here it's popping out Python 3.5 so if we want to run it with that Python 2 7 profile again then we can just pull up that command palette and type in script and there's one option here that is run with profile now usually gives the keyboard shortcut over here I'm not sure why it's not showing up now with the keyboard shortcut on a Mac is command shift K so now that I clicked on run with profile then you can see that it pops up with the profiles that I have available and we've only made c1 Python 2 7 1 so now I can run it with that and down here at the bottom this is the output for this for the system is Python 2.7 so it did run that correctly and you can set those run options up for multiple versions of Python or you can point to any virtual environment if you need to run a Python and a virtual environment so I think that's going to do it for this video that is everything specific to how I setup a Python development environment within atom I hope people found this useful the most popular questions I get on this channel are people asking how to setup Python development environments and what I recommend so like I mentioned earlier I also use sublime text and have done a video on how to set up a Python environment within sublime text also and I'll put a link to that video in the description section below now if anyone is wondering if I would recommend sublime text or atom then I would just say that it depends so I think that atom is more user friendly if you're just getting started out and if you don't want to purchase sublime text then I would say that atom is a great option but I've been using sublime text for so long that I'm more used to it and I find myself going back to it often but really the choice is just up to you and whichever you prefer so hopefully having videos on how to set up and armaments and both of these editors now you can play around with them and just decide which one you personally like more so if anyone has any questions about what we covered in this video then feel free to ask in the comment section below and I'll do my best to answer those if you enjoyed these tutorials and would like to support them then there are several ways you can do that the easiest way is just to simply like the video and give it a thumbs up and also it's a huge help to share these videos with anyone who you think would find them useful and if you have the means you can contribute through patreon and there's a link to that page in the description section below be sure to subscribe for future videos and thank you all for watching
Info
Channel: Corey Schafer
Views: 564,153
Rating: 4.9293675 out of 5
Keywords: Atom, Python, Atomio, Python Atom, Development Environment, Dev Environment, GitHub, Atom Packages, Programming Tutorials, Python Tutorial, Atom Tutorial, Software Engineering, How to, How-to, PreDawn
Id: DjEuROpsvp4
Channel Id: undefined
Length: 23min 0sec (1380 seconds)
Published: Wed Feb 15 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.