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