Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Install Requirements From Another Folder

00:00 To clear the terminal and forget a bit about the detour that I made us do. I used the clear command. Now I need to deactivate the virtual environment I’m in right now because it’s the one at a pip exercises folder.

00:13 And we want to go into the other exercises. So I use deactivate. And now to move into the other exercises folder, I’ll use one command instead of two commands before I used cd .. and then cd to the other exercises folder.

00:29 But you can combine this in one command by using cd ../ and then the other exercises folder.

00:38 Basically, your file pointer follows you into the parent directory and then into the other exercises directory. And once you press enter, you can verify that this worked by using pwd.

00:50 And as you can see, you are now in the other exercises folder.

00:54 One very important thing now is to activate the virtual environment there source

01:03 bin/activate.

01:07 And once you have activated this virtual environment, you can use a similar path that you use with cd, but this time you point to the requirements file of the other directory.

01:18 That is one solution to how to install the packages with one command. And that’s python3 -m pip install -r. That means I want to point to a requirements file and then ../ pip_exercises/.

01:43 And now the requirements file, which is requirements

01:48 .txt, once you press enter

01:54 pip is collecting the information from the requirements file and installing them into your current virtual environment. Now you also get this pip install --upgrade pip command warning that you did in a formal lesson because you have a new virtual environment created for this folder, which has the older pip version in it.

02:14 So you can update pip here again. But for now, I don’t care that much about it because it still works. And to see that it actually worked, let’s use python3 -m pip list.

02:30 And there you can see there is the rich package in version 13.5 and requests in the version 2.31, which is larger than two. Perfect. So that’s one solution to this part of the challenge.

02:45 In the next lesson, I will show you another solution.

Become a Member to join the conversation.