1
00:00:05,200 --> 00:00:07,680
Alright, so we've seen that we can
have a Python installation that's

2
00:00:07,680 --> 00:00:11,440
separate from our main installation.
So how do we know which Python will be

3
00:00:11,440 --> 00:00:14,639
used when we run our program?
The answer to that is, our main

4
00:00:14,640 --> 00:00:18,480
installation will be used by default.
Now we can easily confirm that.

5
00:00:18,480 --> 00:00:22,000
We didn't install colorama
in our main installation of Python,

6
00:00:22,000 --> 00:00:24,480
so therefore our code should crash 
when we run it.

7
00:00:24,480 --> 00:00:28,040
So switching back to the command line, or
terminal session, from a couple of

8
00:00:28,040 --> 00:00:30,000
videos ago, and you can see, I've still got mine open

9
00:00:30,000 --> 00:00:33,760
from a few videos ago. So you should
still be in your project directory.

10
00:00:33,760 --> 00:00:37,200
If not, maybe because you've closed down
the command prompt since then,

11
00:00:37,200 --> 00:00:40,559
repeat the earlier steps to change back
into your project directory.

12
00:00:40,560 --> 00:00:44,520
In my case, you can still see that I'm
still there. So if you need to do that,

13
00:00:44,520 --> 00:00:48,399
refer to your notes on how to do
that. You did take notes, didn't you?

14
00:00:48,399 --> 00:00:52,800
Right? If not, watch the video, running
your program like a user again,

15
00:00:52,800 --> 00:00:56,399
and take notes this time. Alright. So
I'm in my project directory, and I'm

16
00:00:56,399 --> 00:00:58,960
going to run my colour print
program. So I'm just going

17
00:00:58,960 --> 00:01:02,160
to, basically, use an up arrow here,
and you can see the comment at the

18
00:01:02,160 --> 00:01:05,640
bottom of the screen there;
python colour_print.py.

19
00:01:05,640 --> 00:01:08,640
And just a note here, as a
reminder to use python 3,

20
00:01:08,640 --> 00:01:12,000
if you've also got python 2 installed. In
my case, we established that I've got

21
00:01:12,000 --> 00:01:16,000
python 3 only. I'm gonna press
enter there, and you can see

22
00:01:16,000 --> 00:01:18,720
we've got an error.
So the program's crashed when we try

23
00:01:18,720 --> 00:01:24,720
to import colorama, on line 1;
No module named colorama. That's good

24
00:01:24,720 --> 00:01:28,479
because we've confirmed that we didn't
alter the main installation of Python,

25
00:01:28,479 --> 00:01:32,720
when we installed the colorama package.
When we run our programs in an IDE,

26
00:01:32,720 --> 00:01:35,920
the IDE activates the virtual
environment for us.

27
00:01:35,920 --> 00:01:39,439
We're running now from a command prompt,
so we have to activate the virtual

28
00:01:39,439 --> 00:01:44,320
environment ourselves.
So going back to our IDE again,

29
00:01:44,320 --> 00:01:48,440
I'm just going to quickly run it again
so we've got the run pane.

30
00:01:48,440 --> 00:01:52,000
And the very first line, it shows
the complete path to the Python

31
00:01:52,000 --> 00:01:54,960
interpreter.
That's very useful, because that's the

32
00:01:54,960 --> 00:01:57,520
Python interpreter that we want to
activate.

33
00:01:57,520 --> 00:02:00,399
Make a note of that path because we're
going to need it to activate the virtual

34
00:02:00,399 --> 00:02:02,799
environment.
you can copy the link to the clipboard

35
00:02:02,799 --> 00:02:07,520
but be careful - the link's clickable and will
launch Python if you click it. I find it

36
00:02:07,520 --> 00:02:11,520
easier just to click the mouse just to
the left of the path, over here,

37
00:02:11,520 --> 00:02:16,860
and just use the shift and the right arrow
that I'm using there, to select the path.

38
00:02:16,860 --> 00:02:19,360
Now there's a trick to doing that so that Python

39
00:02:19,360 --> 00:02:22,239
doesn't run. Move the mouse
very slightly sideways before releasing

40
00:02:22,239 --> 00:02:24,160
the mouse button,
but if you can't get the hang of it,

41
00:02:24,160 --> 00:02:26,319
don't worry - just close the
python window that appears.

42
00:02:26,319 --> 00:02:29,200
The cursor will be in the correct place,
and you can use the keyboard to select

43
00:02:29,200 --> 00:02:32,660
the path.
Ctrl-C will then copy it to the clipboard.

44
00:02:32,660 --> 00:02:34,720
Alright, so we'll just go back
because what we actually want to do,

45
00:02:34,720 --> 00:02:39,120
is select up to, but
not including python.exe, or whatever it

46
00:02:39,120 --> 00:02:43,200
says after that slash.
Basically, we don't want to copy the

47
00:02:43,200 --> 00:02:45,760
python from the end, so stop
after the last backslash,

48
00:02:45,760 --> 00:02:48,959
on windows which I'm running now,
or slash on Mac and Linux.

49
00:02:48,959 --> 00:02:51,599
And the reason for that is we want to
activate this and it's done slightly

50
00:02:51,600 --> 00:02:55,880
differently on Windows, and Linux or Macs.

51
00:03:20,900 --> 00:03:23,540
Alright, so I'm back here in my command prompt.

52
00:03:23,540 --> 00:03:27,599
I'm going to paste in the path that I just copied,

53
00:03:27,599 --> 00:03:30,640
and that's the path for me. Now we need
to add a backslash and

54
00:03:30,640 --> 00:03:34,720
activate to the end of that. Now you'll
do something similar on Linux and Mac,

55
00:03:34,720 --> 00:03:37,519
but remember to type source and a space first.

56
00:03:37,519 --> 00:03:42,159
Once we've done that, we're now using the
Python installation

57
00:03:42,159 --> 00:03:46,080
for your virtual environment. Note now,
that the prompt has changed.

58
00:03:46,080 --> 00:03:49,200
In my case, I've got parentheses venv

59
00:03:49,200 --> 00:03:52,319
at the start of the prompt, but you may
have something different like python 38,

60
00:03:52,319 --> 00:03:55,040
or something along those lines.
The bottom line is, with those

61
00:03:55,040 --> 00:03:58,159
parentheses, it indicates that you're
using a virtual environment

62
00:03:58,159 --> 00:04:02,000
to run our programs. Something else to
know is, you no longer have to run

63
00:04:02,000 --> 00:04:04,799
python3. Whichever version of python you

64
00:04:04,799 --> 00:04:09,680
installed in the virtual environment,
you run them all with the command python

65
00:04:09,680 --> 00:04:12,799
in the virtual environment.
Alright, so let's see this working,

66
00:04:12,799 --> 00:04:18,639
but try working now, python colour_print.py,

67
00:04:18,640 --> 00:04:22,520
and we get our output in glorious
technicolor on a Windows 10 computer,

68
00:04:22,520 --> 00:04:29,560
as you can see. Yay. Now it still 
also works on Linux and Mac computers.

69
00:05:16,660 --> 00:05:18,240
Alright, so once you've finished using

70
00:05:18,240 --> 00:05:21,120
your virtual environment, the command to deactivate

71
00:05:21,120 --> 00:05:28,300
is the same on all three operating systems,
and it's literally the word deactivate.

72
00:05:28,320 --> 00:05:31,360
I didn't need to specify a path there
because activating

73
00:05:31,360 --> 00:05:33,479
took care of that for us.

74
00:05:54,360 --> 00:05:57,620
Alright, so I'm going to close my command prompt now,

75
00:05:57,620 --> 00:06:03,520
and I'll see you in the next video.

