1 00:00:00,000 --> 00:00:15,840 So to start it, I'm creating the virtual environment directory using mkdir hello underscore env. 2 00:00:15,840 --> 00:00:29,879 And then cd hello underscore env and python3 minus mvenv, that will create a directory 3 00:00:29,879 --> 00:00:35,000 structure that is needed for the virtual environment. As you can see, the venv directory 4 00:00:36,279 --> 00:00:39,320 and the three commands reveals all the things that are within. 5 00:00:40,360 --> 00:00:45,160 So now the important thing is to source the virtual environment using source venv 6 00:00:45,160 --> 00:00:54,360 slash bin slash activate. And now we can install the required module. So pip install 7 00:00:55,080 --> 00:01:01,240 colorama. And oh, a new version is available. Well, we don't need a new version. Feel free 8 00:01:01,240 --> 00:01:07,000 to use pip install minus minus upgrade pip to install the newer version of pip. But for now, 9 00:01:07,000 --> 00:01:12,279 we're good. Then I'm going to freeze the current requirements that have been used 10 00:01:12,279 --> 00:01:21,080 in requirements dot txt. And now it's time to write the script. Okay, so let's create the script 11 00:01:21,559 --> 00:01:30,440 and call it myscript dot py. And in the script as a comment, I'm keeping the name myscript 12 00:01:32,360 --> 00:01:41,559 dot py. And then I'm starting by importing date time. And from colorama, 13 00:01:43,720 --> 00:01:50,360 which we just installed, import four. So here we have an import of two functions. One of them 14 00:01:50,360 --> 00:01:57,000 is an internal one. The other one is coming from the module. Now I'm defining the variable now. 15 00:01:57,879 --> 00:02:09,639 And now is set to date time dot date time dot now. Close it with opening and closing parentheses. 16 00:02:09,639 --> 00:02:15,399 And then we can have the core of the script, which is using print four dot green 17 00:02:17,399 --> 00:02:26,600 plus f current time colon now. And I'm going to make a small typo so that you can see what 18 00:02:26,600 --> 00:02:35,559 is going on if you have typos. So let's try to run it using Python on myscript dot py. 19 00:02:36,039 --> 00:02:41,720 And as you can see, Python is telling that something is not all right. It's telling us 20 00:02:41,720 --> 00:02:48,520 that the not all right is on the closing double quote. So that's easy to fix. And obviously, 21 00:02:48,520 --> 00:02:53,960 the closing double quote needs to be behind and not in front of the closing parentheses. 22 00:02:54,839 --> 00:02:59,080 So here we run it again. And there we can see that in nice green color, 23 00:02:59,080 --> 00:03:04,279 it prints the current date and time. And that concludes our simple lab exercise.