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

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Re-creating a Development Environment

00:00 Now I want to re-create exactly this development environment in another folder. You can think of this as the steps your friend would do or what you would do if you want to continue working on your project on another computer. First, create a new folder. The one before was creatively named project, so let’s name this one same_project. You type mkdir same_project, and then hit Enter.

00:33 You change into the new folder with cd same_project. Inside the folder, create a new virtual environment, python3

00:46 -m venv venv, and activate it with source venv/bin/activate.

00:55 So far, there are no packages installed in this virtual environment, but let’s check that with pip list. python3 -m pip list. All right, so that means when I type python3 -m rich, I get an error because this package is not installed yet.

01:17 Okay, before we continue, let’s clear the screen again.

01:22 Next, I want to copy the requirements file from the former project folder into the current one. For this, you can use the cp command. You type cp ../project/requirements.txt and then a space and then ./requirements.txt With a command like this, you have to think from the perspective of your current directory you are in. The .. is an alias for the parent directory, and there you find the project folder of the requirements file.

02:01 That’s the item you want to copy. The second part of the command is the target path, which is ./requirements.txt. The . stands for the current directory, and requirements.txt is the filename. When you press Enter, you copy the requirements file from the folder project/ into your current directory.

02:25 Let’s check it out if it worked by typing ls. Okay, cool, you see your venv folder and the requirements file. But having the requirements file in your project directory and an activated virtual environment is not enough.

02:41 You also need to install the requirements. For this, you run python3 -m pip install—that’s a command you already know—and then a space -r space requirements.txt And this installs exactly the packages with exactly the versions you froze in the other project folder because they are all saved in the requirements.txt file.

03:09 Now both development environments are exactly the same. Let’s verify this by running python3 -m pip list. Cool. Okay, so that means rich is present, and python3 -m rich works. Wonderful!

03:30 I don’t know about you, but I could look at this terminal forever.

03:34 Anyway, once you’re ready, let’s meet in the next lesson. There, I’ll show you how to find third-party packages on your own.

Become a Member to join the conversation.