Effective PyCharm Transcripts
Chapter: PyCharm Projects
Lecture: Creating projects

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Let's start by creating a new project. Now, I would normally just open a PyCharm and create the project
0:09 but I want to make sure that you have everything that we're doing in this course so remember, our github repository over here,
0:16 I'm going to clone this really quick just to take you through the whole life cycle so we'll come over here, we'll go to our desktop
0:24 and we're going to clone this using the git command. We could do this with PyCharm but you'll see there's one piece that maybe gets missed
0:32 that I really like to do when we're getting started, but I'll show you where you could clone this from PyCharm directly.
0:39 We'll say git clone this, and I'll just call this course, and I'll put it on the desktop. Okay, so you can see that appeared over here,
0:51 now we're going to create a folder in here called demos and in the demos folder, this will be projects, so this is the project section.
1:00 So here is where I want to work, let's go over to PyCharm and you can see when you're in PyCharm it has the projects that you previously worked with,
1:09 this one is from the MongoDB course, and we're going to create a new project. Now, I'll do it this way first here, but in general,
1:17 I actually do a few steps on the command line before we get going which I'll do in the next section here. So we can start a brand new project
1:26 and we can come over here and say we're going to browse to it and I want it in this location, in the demos, in the projects
1:35 and maybe we want to make a subdirectory here because we might have more than just one. So I'll call this first project.
1:42 Now notice, it's proposing that we use some kind of Python interpreter, obviously that is required, but it turns out there are a lot of options,
1:50 here's a bunch of virtual environments that no longer are valid I have to go back and clean that up, I could even go over here and I could say
1:57 add a local alternative version that could be Python 3.6 that we have here or it could be like PyPy, something like that,
2:04 I could even add a remote one over ssh or create a new virtual environment. I'll just go with this one for now, the system default one
2:14 and this is going to create just a basic Python project, it will be empty, we'll create files and so on.
2:20 If you want more structure, something that is not empty we could go with Django, if we click here you'll see
2:25 it will actually give you all the settings to set up the various templating languages and things like that,
2:31 or Flask, Pyramid, one of my favorites, you can pick all the things that you might do from say the cookiecutter template that comes from there,
2:40 there's a bunch of sort of frontend things down here as well, also Web2py. But, we want to do this one, so let's say create
2:46 and notice it's going to run down here just for a second and index all of the Python files in our main Python environment,
2:56 it also says, "Hey look, this is some kind of git repository, would you like to add it?"
3:03 basically tell this project to understand the version control settings that it found in the file structure, so yeah, we definitely want that.
3:11 So over here, we have no files in our projects, and these external libraries, these are the various things installed in Python
3:18 this basically lets you look into the selected Python environment here. So we're not going to worry about that right,
3:27 we can just basically ignore the external libraries. We'll come up here and we'll say new, and you can pick a whole bunch of different things here,
3:35 it could be an HTML file, it could be TypeScript but we're going to go with Python.
3:41 In Python it will be, "Hello," maybe do a quick little, "Hello world," and notice, right away because we said yes
3:47 to understanding or incorporating that git hierarchy that it found, it says we're going to automatically add this file,
3:53 do a git add on that file to our project. You could say yes or no, I'll just say yeah, you always do that, that's fine,
4:01 and notice over here, that means it's green, because it's now staged but not committed in git
4:07 so I'll just print, "Hello world," we'll talk about the editor a lot, we're going to spend a whole chapter on that,
4:15 but for now, I really just want to focus on the files here, if we had some other file just add some other file, other file, like that,
4:22 we could have a method, just print out something, this is the other method, we'll come back to play with that in a little bit.
4:33 Notice, as I discussed in introduction, down here we have the presentation assistant, so mostly you'll see me working with hotkeys not menu items,
4:43 but that'll tell you what the hotkey was as well as what the menu item would have been.
4:49 Okay, so now we have this project and we're pretty much ready to go, we should be able to run it or something somehow.
4:55 But if you look over here, this whole little area about running and debugging and testing and whatnot
5:00 it's all grayed out, it has no idea what to do with these files. So the next thing that we need to do is we need to say which of these files to run,
5:08 how to run it, what command line arguments to pass and so on. So the way you do that is you right click on one,
5:13 you create what's called a run configuration by picking one of these options down in this little area here,
5:18 so we'll say run, and it immediately runs down here, it runs with the selected version of Python that we had
5:26 and it ran the file that is here in my desktop and just here is the output, it said, "Hello world," or whatever it is that the script does,
5:39 and once you've done that, there's now what's called a run configuration that lives up here and we can run it over and over,
5:45 we can run it with hotkeys, control r on Mac, we can even debug into it, run it with coverage all those sorts of things.
5:52 So, that's how you create new projects in PyCharm.


Talk Python's Mastodon Michael Kennedy's Mastodon