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

Freeze the Project Requirements

00:00 There’s this German saying “Wer es nicht im Kopf hat, muss es in den Füßen haben,” which basically translates to “If you don’t have it in your head, you have it in your feet.” I don’t know if that makes sense in English, but it basically means something my grandpa always said: if you forget about something, then you need to walk there to do it again.

00:17 That’s what I did with the requirements file. So file, that’s why I need to do a little bit of detour there to freeze my requirements in the pip exercises folder.

00:27 Before that, I want to deactivate the virtual environment that I’m in right now, which was the one in other exercises. Then I change into the parent directory.

00:38 From the parent directory, I go into the pip exercises folder,

00:45 and there I activate the virtual environment again, and that’s actually pretty important because if you would just freeze the packages into the requirements file without activating the virtual environment, you would freeze the packages that you have in your system Python, but you want the one from your virtual environment.

01:03 So once you have activated the virtual environment, you can use python3 -m pip freeze.

01:14 Again, let’s just press enter to see the requirements to make sure that we’re using the correct ones and they are, and then we can save the output with the greater than symbol into the requirements.txt file.

01:30 Once we have done that, let’s quickly check what’s in the requirements.txt file with the cat command. There you can see these are the packages that we want to use in our other virtual environment, and that’s what we’ll do in the next lesson.

Become a Member to join the conversation.