Full Web Apps with FastAPI Transcripts
Chapter: Deploying FastAPI on Linux with gunicorn and nginx
Lecture: venv forever
0:00 On the server, it's only
0:01 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 gonna show you is that. Lets ask really
0:12 which python3 real quick.
0:13 So we know where it is, there. Having
0:16 that directory is gonna help. What I'm gonna propose is that we change our login.
0:19 So as we log in,
0:20 it just activates that virtual environment.
0:22 Otherwise, 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 wanna 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 ~/.zshrc, go down to the bottom here
0:40 and we'll say source that bin, instead of Python, we'll say activate like that. If I exit
0:46 out and I log back in.
0:49 Look at this. Yes, that'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 on web app.
1:04 If you've got 20 we 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.