Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,840 --> 00:00:02,520
Hi, and welcome back.
2
00:00:02,640 --> 00:00:09,420
In this video, I'd like to show you another way to execute Python scripts, and that's using the terminal
3
00:00:09,450 --> 00:00:10,770
or the command line.
4
00:00:10,830 --> 00:00:18,540
This is especially useful when you connect to a remote machine or server using, for example, SSH and
5
00:00:18,540 --> 00:00:20,850
run the python script on that machine.
6
00:00:21,710 --> 00:00:30,140
You don't have access to a graphical environment to open python idle or pitch time to execute the script.
7
00:00:30,320 --> 00:00:36,020
In fact, in this case, this is the only way to execute the script.
8
00:00:37,260 --> 00:00:42,780
Let's create a Python script using any editor like Notepad or even Pixar.
9
00:00:42,930 --> 00:00:45,750
You can use any other editor you like.
10
00:00:48,430 --> 00:00:55,060
I'll write some Python instructions inside the script and the save it on the desktop.
11
00:00:56,760 --> 00:00:57,960
Name equals.
12
00:00:58,870 --> 00:01:02,860
Entry in a single coax and print.
13
00:01:03,800 --> 00:01:04,670
Hello.
14
00:01:05,750 --> 00:01:06,980
My name.
15
00:01:08,580 --> 00:01:13,940
I'm saving the script on my desktop is my script to that PI.
16
00:01:20,190 --> 00:01:21,360
This is the script.
17
00:01:22,150 --> 00:01:27,580
Now I'll open cmd dot xy or a command prompt.
18
00:01:27,610 --> 00:01:28,900
Go to desktop.
19
00:01:31,360 --> 00:01:35,740
Check the content of the current directory by running the command.
20
00:01:36,700 --> 00:01:38,140
In the run Python.
21
00:01:39,250 --> 00:01:40,570
And the name of the script.
22
00:01:43,150 --> 00:01:45,790
And you see how the script has been executed.
23
00:01:46,640 --> 00:01:54,800
If you use Linux or Mac, open the Linux or the Mac terminal instead of CMD, ATX C and run Python three
24
00:01:54,800 --> 00:01:56,040
instead of Python.
25
00:01:56,060 --> 00:02:02,960
If you are not in the same directory as the Python script, you must use a valid, absolute or a relative
26
00:02:02,960 --> 00:02:03,560
path.
27
00:02:03,590 --> 00:02:05,720
Otherwise you'll get an error.
28
00:02:07,320 --> 00:02:10,770
For example, I'm moving to the parent directory.
29
00:02:12,220 --> 00:02:16,210
If I try to execute the script by running the same command.
30
00:02:16,210 --> 00:02:20,230
So Python and the name of the script, I'll get an error.
31
00:02:21,640 --> 00:02:24,670
That's not a valid path to the Python script.
32
00:02:25,990 --> 00:02:28,120
No such file or directory.
33
00:02:30,030 --> 00:02:33,300
Now I'm running the script using the correct path.
34
00:02:33,960 --> 00:02:38,460
So Python, they stop with a capital D.
35
00:02:40,330 --> 00:02:42,040
Slash or backslash.
36
00:02:42,070 --> 00:02:43,960
You can use either of them.
37
00:02:44,140 --> 00:02:45,520
And the name of the script.
38
00:02:46,420 --> 00:02:48,490
My script to that pi.
39
00:02:51,340 --> 00:02:51,730
Index.
40
00:02:51,730 --> 00:02:52,300
Okay.
41
00:02:55,160 --> 00:02:57,410
The script was run successfully.
42
00:02:59,260 --> 00:02:59,920
Great.
43
00:02:59,950 --> 00:03:05,410
In this lecture you've learnt how to run Python scripts directly in the terminal.
44
00:03:05,500 --> 00:03:11,860
This is useful when you want to run a Python script on a machine without a graphical environment such
45
00:03:11,860 --> 00:03:18,010
as a server or on a computer without PI charm or other ID installed.
46
00:03:18,190 --> 00:03:22,180
Of course python should be installed on that machine.
47
00:03:22,540 --> 00:03:29,980
With this video we have completed the first section of the course on set up the programming environment.
48
00:03:30,010 --> 00:03:36,310
So next we are going to have a quick quiz just to make sure that you've deeply understood how to run
49
00:03:36,310 --> 00:03:37,480
your Python scripts.
50
00:03:37,630 --> 00:03:44,680
Good luck with the quiz and I'll see you in the next section where we'll talk about Python basics,
51
00:03:44,680 --> 00:03:51,280
such as variables, comics built in data types, operators and many more.
4402
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.