Work With a Virtual Environment (Solution)
00:00
Okay, it’s finally time to work with virtual environments. We need to create a virtual environment inside the pip_exercises
folder. Let’s see where we are right now by typing pwd
.
00:13
So I’m on the desktop and with ls
I can see that there is a pip_exercises
folder. So I can cd
into this folder.
00:24
And to check if I’m into this folder, I use pwd
again, which verifies we navigated into the pip_exercises
folder. And then we create a virtual environment named venv
.
00:36
And we can do this by using python3 -m
and then you call the venv
module and you create a virtual environment named venv
.
00:51
And once you press enter, your computer probably works a little bit to create it. And if you press ls
, you can see that there is now a venv
folder in your pip_exercises
folder.
01:05 Since I have my file explorer open on the right side, I can also click this little arrow here. And you can see that there is the virtual environment folder successfully created, but it’s not just a folder.
01:18 There is a bunch of stuff in this folder. So let’s click this one here. And as you can see, there are a few folders in there, but you don’t need to bother that much about it.
01:29 The important thing is you have this virtual environment folder now, but to actually work with the virtual environment, you need to activate it. So let’s go back to the terminal and activate the virtual environment.
01:40
And this you do with source
and then venv/
that’s the virtual environment folder bin/
activate
.
01:51
And once you press enter, you can see on the left side that there is (venv)
in parentheses now at the left side of your prompt. And this indicates that you successfully activated the virtual environment.
Become a Member to join the conversation.