Locked learning resources

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

Unlock This Lesson

Locked learning resources

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

Unlock This Lesson

Chain Package Names

00:00 And for this other solution, I want to create a second virtual environment to start fresh. So I deactivate the one that I’m in right now with deactivate,

00:11 and then I clear the screen.

00:15 And basically, if you name a virtual environment differently, there is nothing stopping you from having multiple virtual environments in the same folder.

00:24 So if I use python3 -m

00:29 venv and then let’s say venv2 with the number two in the end and I press enter, then you can see on the right side that there is a second folder named venv2.

00:41 This could make sense if you want to work with different packages and you should then name the virtual environment probably a bit better than venv2.

00:50 But for this course, that’s okay. It’s just to make the point of that you can have multiple virtual environments. And then to activate it, of course, you need to use venv2.

01:00 That’s the name of the new folder. And then bin/activate. So it’s source venv2/bin/activate. And when you activate it and you check with python3 -m pip list that, oh, of course, there needs to be a pip in there somewhere.

01:21 So python3 -m pip list.

01:27 Then you can see that there’s currently only pip and setuptools there. So now again, the task is to install both packages with one command before we referenced a requirements file in a different folder, but here we want to use basically one pip install command, but just referencing multiple packages in one line, which also is possible with pip.

01:51 So python3 -m pip install. And now the first package is requests, which should be larger than 2.0.

02:06 I put this in quotes again to not confuse my terminal. And then with the space afterwards again and quotes rich==13.5 because I want exactly the version 13.5 and that’s why I have to use two equal signs.

02:24 And then I close it off with the quote. Again, when I press enter, I’m collecting the requests package and the rich package and all the dependencies that those two packages need to have.

02:38 And to check if everything worked, I can use python 3 -m pip list again. And now you can see that there are more packages in your virtual environment, including Rich 13.5 and requests 2.31, which is larger than zero.

02:58 So that’s the second solution. And then the next lesson, I will show you a third solution.

Become a Member to join the conversation.