Mastering PyCharm Transcripts
Chapter: PyCharm Projects
Lecture: Search everywhere

Login or purchase this course to watch this video and the rest of the course contents.
0:01 The next thing that we are going to talk about
0:03 is searching and navigating within a project.
0:05 These little simple applications, even the Jumpstart one,
0:08 really are a little too simplistic for that,
0:10 so what I want to do is grab a more complicated application for us to work with.
0:16 So over here at the MongoDB quick start course
0:18 I wrote a little AirBnB knock off type thing
0:21 so let's go and clone this as well, we'll go over here,
0:26 go back and this will be quick review of opening an existing project,
0:29 so we're going to come down here and say git clone that,
0:33 and I'll just call it into Mongo, okay go here
0:39 and then we'll create a virtual environment, and then we'll go open it.
0:44 This is actually the same one that you already saw, but that's ok.
0:48 Let's go over here to this, this is the one that was already in my reaching files
0:53 but I want to make sure you can get started as well
0:55 so yeah, we'll add that root, that's fine.
0:58 We're actually not going to check anything back in, but that's ok.
1:01 So over here you can see here is our program,
1:03 here is our source root and so on,
1:06 so what we really need to do to get started
1:08 if I open up this for example everything is broken,
1:12 so we're going to go over here
1:13 and we going to say mark directory as sources root
1:16 now that all fixes that,
1:19 this actually depends upon MongoEngine and tqdm
1:23 how does it know— this is pretty awesome, this is part of the project stuff,
1:26 so look over in this requirements file,
1:29 most major projects have at their root a requirements file,
1:33 it says these are the modules that I depend upon
1:36 and PyCharm knows that and it says,
1:39 well look, these packages from PyPi— they're not here;
1:43 how does it know— well, we have our virtual environment
1:49 which I guess I created in the wrong place,
1:52 it didn't exist so where did I create it—
1:55 so I did it in the main root, not the one down here, so let's go and add that.
1:59 So we come over here to preferences,
2:02 on Mac you always say Command + comma
2:05 pretty much any app and it will take you there,
2:08 we can just come down here to project, way down here,
2:12 go to projects interpreter, and see it's using the main one
2:16 so we'll go over here and say add local
2:19 and this is going to be in users screencaster desktop mongo in there,
2:29 the exact path varies by Windows or Mac,
2:32 I believe it's in scripts not bin on Windows
2:35 but over here you can see it says which things are here
2:38 and if we switch that back, it'll say guess what— give it a second index,
2:44 yeah, now there's even fewer things installed
2:47 all of those requirements are missing because this is totally empty.
2:51 Why we're here— notice over here this UI
2:54 actually would let us do things like install,
2:57 I can come over and say MongoEngine,
2:59 and it'll actually find all the stuff to do with MongoEngine
3:02 and let me install that package right there.
3:05 We're not really going to run this app
3:07 because we don't have Mongo set up correctly for it right now,
3:10 but I can click this button and even upgrade it,
3:13 notice this is now upgrades so that's pretty sweet,
3:15 it lets you manage the environment
3:17 but we don't have the things that are required there,
3:20 if I exit out and come back to my terminal
3:22 you can see now my environment is active,
3:27 I could come over here and say pip install -r requirements
3:33 notice I get auto complete, because this is my zsh shell even,
3:39 so it even remembers your previous commands and whatnot,
3:41 but I could do this, that's what I would possibly normally do
3:45 but in PyCharm, it just says, you need to run
3:48 that command I just typed, so let me just click it here,
3:51 choose what you want to do and wait a moment,
3:55 and it will download and install this.
3:59 So it installed them and ran for just a second to index those new packages
4:04 and there you go, that's all good, we can make that go away.
4:09 And now, all of our little warnings go away everything is good
4:12 so even in our data section over here where we say important MongoEngine
4:16 that works, because PyCharm saw the requirements file
4:23 and it installed it for us an indexed it and so on. So that is really cool.
4:30 So now we have this project,
4:32 we want to navigate around, it understands all the pieces.
4:35 The first thing you might be doing is like maybe we know
4:39 somewhere over here, maybe there's something called book_cage
4:44 and we know there's a method called book_cage
4:48 but is it in infrastructure, is it in services,
4:54 I can't remember where it was,
4:56 so let's suppose we're trying to find a method called book_cage.
4:59 So what we can do is, there's little search thing up here you can click,
5:03 but I never click that, what I do is I hit double shift
5:07 and this is super helpful, the first thing you see are recent files, so Mongo setup,
5:12 let me show you something that's really cool about this.
5:16 Suppose I have that part selected, I was working here
5:19 actually let me pick a bigger file there, I can scroll way down,
5:24 suppose I have line 71 to 75 selected,
5:27 close these all off and that was in the data service file
5:32 so if I do the double shift, you can see right here there is a search everywhere
5:36 it's going to remember data service.
5:39 Now, it doesn't just remember, oh you had this file open,
5:42 when I open it, it puts it exactly like it was
5:46 so if I have stuff collapsed, I'm trying to understand this at a high level
5:51 so I've collapsed most of these methods, and things like that,
5:54 and I had that selected, it would come back just like this.
6:00 This is super awesome, so this double shift open up the recent files
6:05 is actually a major way that I navigate throughout my applications
6:09 because it doesn't just remember what you recently had opened
6:14 which is really nice after you close it,
6:16 but it actually remembers the state of the files,
6:20 where you were, what you had selected,
6:22 it really takes you back to where you started.
6:25 That's great, but we were looking for something called book_cage,
6:28 so if I just type book, you can see there's some classes
6:31 there's a booking class, this is a thing we stored in MongoDB,
6:34 this is the file that contains the booking class, here it shows you just the files,
6:41 there's some symbols, and look at that, book_a_cage,
6:45 this is the guest version, this is like the low level data version,
6:49 this is how I can get the book into my cage and so on,
6:53 then there's even actions, look at that, how do I create a bookmark
6:57 or these are literally menu options in PyCharm.
7:00 Alright, it looks like book_cage that's the one I was looking for,
7:03 bam, I can navigate to it just like that.
7:06 So this search everywhere is really helpful,
7:09 it works for Python, but it also works for text files, CSVs, Javascript, you name it,
7:17 CSS, it doesn't matter so I can come over here and say Colorama,
7:25 and it will take me into there.
7:27 Notice that I can include non-project items as well
7:30 and it will look inside, it's looking inside the PIL package in Python,
7:38 so you can even search the standard library that way,
7:41 I could look for dict for example in built in, we can go straight to dict.
7:45 Now, you don't get too many details because this is just
7:48 it's implemented in C in the C Python runtime,
7:53 but at least it will give you the signatures best as it can tell.