Join us and get access to thousands of tutorials and a community of expert Pythonistas.
This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.
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 ..
00:26
and then cd to the other_exercises folder. 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: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 former 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.
02:42 So that’s one solution to this part of the challenge. In the next lesson, I will show you another solution.
Become a Member to join the conversation.