Full Web Apps with FastAPI Transcripts
Chapter: Deploying FastAPI on Linux with gunicorn and nginx
Lecture: venv forever
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
On the server, it's only purpose is to run this web application. To run this web application, we need to have the virtual environment activated.
0:09
So what I'm gonna show you is that. Lets ask really which Python3 real quick. So we know where it is, there. Having
0:17
that directory is gonna help. What I'm gonna propose is that we change our login. So as we log in, it just activates that virtual environment.
0:23
Otherwise, we do Python stuff, pip and Python and so on. It's gonna work with the system one. We almost never, ever wanna change it.
0:30
We almost always just want to work with this one virtual environment, so let's just make that the default.
0:36
So we'd say nano ~/.zshrc, go down to the bottom here and we'll say source that bin, instead of Python, we'll say activate like that. If I exit
0:47
out and I log back in. Look at this. Yes, that's the right one. If I "pip list", it's all the stuff that we just installed, FastAPI and so on.
0:58
That's super cool, right? So I totally recommend that you set it up so when you log into your server,
1:03
it just sets up the environment for that one on web app. If you've got 20 we apps and all sorts of things going on,
1:08
maybe it doesn't make sense. In this simple world, I think this is the best thing to do.