Install Specific Package Versions
00:00
All right, let’s recreate the development environment. So the development environment is basically what we are having in our pip_exercises
folder.
00:09 And now in this challenge, we need to move everything into the other exercises folder, or not move, copy, that’s a better term for it. But before that, we need to activate our virtual environment.
00:21
As you can see in my terminal on the left, I already did this, but let’s do it together again. I forgot to mention, we’re currently in the pip_exercises
folder.
00:31 So deactivate the virtual environment for a moment
00:37
and then activate it again with source venv/
That’s my virtual environment. Folder
00:45
bin/activate
. And as you can see on the left, the venv
in parentheses is there again. So that means the virtual environment is activated.
00:57
Then you need to install the requests
package with a version above 2.0. If you’re just installing a package with PIP, without declaring any version number, then you are basically installing the latest version for your Python version.
01:13
But here we want to be precise. So the beginning of the command is the same one, it’s python -m pip install
. Then the package name, which is requests
.
01:27
But now we need to define the actual version number, and this one should be above 2.0. So you use the greater than symbol and then 2.0
01:43 to be really sure that this command works. It can be a good idea to put quotes around the package name that you want to install, so at the beginning and after the version number, because sometimes the terminal has a hard time interpreting what exactly you mean by this.
02:02
Because as you learned in a former lesson, you can use the greater than symbol to put the output into a file. So when you put quotes around requests>2.0
, you’re sure that this will work.
02:16
When you press enter, then you are collecting the requests
package and installing it. And now you want to have the rich
package with version 13.5.
02:28
For this first, let’s list what packages are currently installed because we installed the rich
package before python -m pip list
,
02:40
and there we have the rich
package, but it’s in version 13.7. And in this challenge, we want 13.5. So we need to install that version and you can basically just overwrite your current version if you are using the same PIP command with a different version.
03:00
Number python3 -m
pip install
. This time, I again, start with the quotes rich
and now ==
03:16 And then a closing quote again. And if you press enter, then you see that I used a comma instead of a dot. So you can use the arrow up to go to your former command if you made the same mistake as I did.
03:30
And then 13.5
. And when you now press enter, then you can see that PIP is downloading rich 13.5
. And down below you see successfully uninstalled rich 13.7
and successfully installed rich 13.5
.
03:51
Let’s use the up arrow again to get to the pip list
command, press enter. And there you can see we have Rich 13.5
and requests
in a version larger than 2.0, which here is 2.31
.
Become a Member to join the conversation.