1
00:00:05,759 --> 00:00:08,880
For this video, you'll need to make sure
you understand your computer's

2
00:00:08,880 --> 00:00:12,160
file system. If you don't understand file paths,

3
00:00:12,160 --> 00:00:15,599
spend a bit of time learning about them.
This is a course on programming your

4
00:00:15,599 --> 00:00:18,400
computer, not about how to use one.
I'll be showing

5
00:00:18,400 --> 00:00:21,039
the basics of how to change into the
correct directory,

6
00:00:21,039 --> 00:00:24,960
from a windows command prompt, or
terminal session on Linux and Mac.

7
00:00:24,960 --> 00:00:28,640
But time spent getting to grips with
your operating system's file system

8
00:00:28,640 --> 00:00:32,558
will pay huge dividends in the future.
Alright, so make sure you've got your

9
00:00:32,558 --> 00:00:38,079
Functions_Intro project open, as I have,
and expand the project pane.

10
00:00:38,079 --> 00:00:42,079
I'm going to right click on colour_print.py.

11
00:00:42,879 --> 00:00:46,559
There's a couple of options you can use
to find the directory that contains our

12
00:00:46,559 --> 00:00:49,680
Python files.
Open in Terminal is quite a useful one -

13
00:00:49,680 --> 00:00:53,199
you can see that down the bottom there -
even if you're not going to use it for

14
00:00:53,199 --> 00:00:58,640
what it was intended for. I'm going to
choose that option. If I do that now -

15
00:00:58,640 --> 00:01:04,159
and I'll just make a bit more space here -
see that IntelliJ has opened a terminal

16
00:01:04,159 --> 00:01:07,360
in the directory that contains our colour_print file.

17
00:01:07,360 --> 00:01:10,400
Now, I've got a very long path there, as
you can see

18
00:01:10,400 --> 00:01:13,840
and that's because I store my projects on a
network server. But more than likely,

19
00:01:13,840 --> 00:01:17,759
you'll have a much shorter path showing
in your installation of IntelliJ.

20
00:01:17,760 --> 00:01:21,740
Now we don't want to run the program in
this terminal. The whole point of this video

21
00:01:21,740 --> 00:01:23,600
is to run the program like our users will,

22
00:01:23,600 --> 00:01:27,600
and they're very unlikely to be using an
IDE. But the good news is that we get the

23
00:01:27,600 --> 00:01:31,040
full path appearing.
It's got a greater than symbol after it,

24
00:01:31,040 --> 00:01:34,560
as you can see there, which makes copying
the path a bit error prone.

25
00:01:34,560 --> 00:01:38,620
If you're on windows, type the command cd
and press enter,

26
00:01:38,620 --> 00:01:43,360
and I'm on windows so I'll do that.
Don't do that if you're on a Mac or

27
00:01:43,360 --> 00:01:47,840
using Linux. Instead type the command pwd.
Now I won't press enter because this

28
00:01:47,840 --> 00:01:49,920
command won't work on
my windows computer,

29
00:01:49,920 --> 00:01:55,520
but if you're using Linux or a Mac, press
enter after that command. So pwd,

30
00:01:55,520 --> 00:01:58,880
in the case of Mac and Linux users, will
print the full path to your file,

31
00:01:58,880 --> 00:02:04,680
just like cd did for windows users. Alright,
so select the full path, which I'll do now.

32
00:02:04,680 --> 00:02:07,800
Again, mine's quite a long one because I'm using a network drive.

33
00:02:07,800 --> 00:02:09,119
Copy it to your clipboard.

34
00:02:09,119 --> 00:02:13,040
Now unlike terminal sessions on windows,
generally, the IntelliJ terminal does

35
00:02:13,040 --> 00:02:17,440
allow you to use Ctrl_C to copy. So I'll do
that now. So I've taken a copy of that.

36
00:02:17,440 --> 00:02:18,880
Now that we know where we're going,

37
00:02:18,880 --> 00:02:22,800
we can open up a command prompt or
terminal.

38
00:02:42,700 --> 00:02:44,920
Alright, so I'm using windows to record these videos.

39
00:02:44,920 --> 00:02:48,940
So I'm going to type command into the search bar.

40
00:02:52,080 --> 00:02:55,519
I'm going to press enter to select
command prompt -

41
00:02:55,519 --> 00:02:58,720
move this over a little bit. Now ordinarily,

42
00:02:58,720 --> 00:03:02,080
you wouldn't have to do this extra step,
but I'm going to type z colon

43
00:03:02,080 --> 00:03:05,920
to go to the z drive, and that's the
network drive that contains

44
00:03:05,920 --> 00:03:09,840
my files. Alright, so the command to
change directory is the same on all

45
00:03:09,840 --> 00:03:14,159
three operating systems; cd
- short for change directory, and paste

46
00:03:14,159 --> 00:03:18,080
in the path from your clipboard.
The safest way to paste into a terminal is

47
00:03:18,080 --> 00:03:20,879
to right click. On Linux and
Mac, you then choose paste

48
00:03:20,879 --> 00:03:24,159
from the menu. In the case of
windows, it'll automatically

49
00:03:24,159 --> 00:03:27,280
paste in the text for you when I right click.

50
00:03:27,280 --> 00:03:31,519
You can see here, that I've got an error,
and the error relates to how I copied

51
00:03:31,519 --> 00:03:33,760
the path, being that it was
so long and spanned two

52
00:03:33,760 --> 00:03:37,360
lines. You can see that
there's been a problem with it, and it

53
00:03:37,360 --> 00:03:40,159
hasn't actually worked. So what I
need to do is do an additional step,

54
00:03:40,159 --> 00:03:43,360
to get into the particular folder
containing my code.

55
00:03:43,360 --> 00:03:47,920
So I'm gonna do an up arrow - two up
arrows. And I'm going to press tab,

56
00:03:47,920 --> 00:03:52,959
and I'm just going to fill out the rest
of the path manually so I can get there -

57
00:03:52,959 --> 00:03:57,280
Functions_Intro - and I'm now in the path
containing the code. So you probably

58
00:03:57,280 --> 00:04:00,959
won't need to do the extra step.
Firstly, in changing the drive, if you're

59
00:04:00,959 --> 00:04:04,480
using one drive on your system,
most likely you won't have a path as

60
00:04:04,480 --> 00:04:08,000
long as the path that I've used. You
won't have to do this additional step.

61
00:04:08,000 --> 00:04:11,840
We're now in our project directory.
Next we need to check how to

62
00:04:11,840 --> 00:04:14,080
run Python.
You already should have done that

63
00:04:14,080 --> 00:04:16,560
when you installed Python,
at the start of the course.

64
00:04:16,560 --> 00:04:20,238
So start by checking if you've got
Python version 2 installed.

65
00:04:20,238 --> 00:04:23,440
Now many Linux distros and Macs probably
will still have it.

66
00:04:23,440 --> 00:04:27,600
It may also be present on Windows.
So type in python

67
00:04:27,600 --> 00:04:32,800
space --version,
and note that there were two dashes

68
00:04:32,800 --> 00:04:36,400
before I typed version. Press enter as I
did, and make a note of the version number

69
00:04:36,400 --> 00:04:39,440
that appears.
It says Python 3 point something -

70
00:04:39,440 --> 00:04:44,240
you can see in my case it says Python
3.7.3 - then you can run Python from the

71
00:04:44,240 --> 00:04:47,120
command python, which I've done.
If you get a

72
00:04:47,120 --> 00:04:50,240
version two point something,
then you may need to use the command

73
00:04:50,240 --> 00:04:54,000
python3 instead.
Now I don't have Python 2 installed on

74
00:04:54,000 --> 00:04:56,320
this computer, so the command
I'm going to use

75
00:04:56,320 --> 00:05:03,460
is python space, and then colour_print.py.

76
00:05:03,460 --> 00:05:09,420
Now when I press enter, our 
program runs, and looks absolutely awful.

77
00:05:09,420 --> 00:05:11,360
On Linux or a Mac, though, you should see

78
00:05:11,360 --> 00:05:15,199
all the colors and other effects.
On Windows, the command prompt doesn't

79
00:05:15,199 --> 00:05:19,120
understand ANSI escape sequences,
and that's why we just get these escape

80
00:05:19,120 --> 00:05:22,400
codes printed out. Now that's obviously not good,

81
00:05:22,400 --> 00:05:26,240
but it does demonstrate why you should
test your programs in a command prompt,

82
00:05:26,240 --> 00:05:31,120
before installing it for your users to
use. Now Windows users have an advantage here.

83
00:05:31,120 --> 00:05:33,360
The program is obviously wrong, and we

84
00:05:33,360 --> 00:05:36,479
know that it needs fixing.
Linux and Mac users might think their

85
00:05:36,479 --> 00:05:40,240
code works fine, and won't find out
there's a problem until someone tries to

86
00:05:40,240 --> 00:05:43,120
run it on Windows.
Okay, so in the next video, we'll see how

87
00:05:43,120 --> 00:05:46,960
to fix this. The video applies, whichever
operating system you're using.

88
00:05:46,960 --> 00:05:50,000
You don't know what your users might be
running your code on. Alright, so keep

89
00:05:50,000 --> 00:05:53,919
this command prompt
or terminal open. We'll be using it again.

90
00:05:53,919 --> 00:05:57,440
See you in the next video.

