Modern APIs with FastAPI and Python Transcripts
Chapter: Deploying FastAPI on Linux with gunicorn and nginx
Lecture: venv forever
0:00 So, on the server, It's
0:01 only purpose is to run this web application. To run this web application,
0:06 we need to have the virtual environment activated.
0:08 So what I'm going to show you is that, let's ask really
0:12 which Python 3 real quick,
0:13 so we know where it, there. Having
0:16 that directory is gonna help. What I'm gonna propose is that we change our log
0:19 in, so as we log in
0:20 it just activates that virtual environment.
0:22 Otherwise, if we do Python stuff,
0:24 Pip and Python and so on,
0:25 It's gonna work with the system one.
0:27 We almost never, ever want to change it.
0:29 We almost always just want to work with this one virtual environment.
0:33 So let's just make that the default.
0:35 So we'd say "nano dot zshrc", go down to the bottom here
0:40 and we'll say source, go to bin, Python will say activate, like that. If I exit
0:46 out and I log back in,
0:49 look at this. Yes, it's the right one. If I "pip list",
0:53 it's all the stuff that we just installed, FastAPI and so on.
0:57 That's super cool, right? So I totally recommend that you set it up so
1:01 when you log into your server,
1:02 it just sets up the environment for that one and Web app.
1:04 If you got 20 Web apps and all sorts of things going on,
1:07 maybe it doesn't make sense. In this simple world,
1:09 I think this is the best thing to do.