1
00:00:00,480 --> 00:00:06,770
As you already know, whenever you want to code a new Python app, what you do is you start pancham.

2
00:00:07,050 --> 00:00:11,970
Then you go to file new project, pick a folder.

3
00:00:12,690 --> 00:00:16,410
For example, I have prepared this with python empty folder.

4
00:00:16,440 --> 00:00:17,550
I'll just pick that.

5
00:00:18,450 --> 00:00:23,700
Sometimes you may write that folder here and python will create an empty folder for you.

6
00:00:23,790 --> 00:00:25,070
Either way is fine.

7
00:00:25,080 --> 00:00:32,910
And then when you press on create, what happens is that Python will produce a virtual environment for

8
00:00:32,910 --> 00:00:34,170
us automatically.

9
00:00:35,050 --> 00:00:42,940
Then we can create Python files from here, and then we can run those Python files using port charm.

10
00:00:42,940 --> 00:00:47,290
So everything happens like magic, which is fine.

11
00:00:47,440 --> 00:00:51,930
The problem with that is that it's a bit of a black box for beginners.

12
00:00:51,940 --> 00:01:01,330
So in this video, what I want to show you is how to create Python apps without using an ID, so that

13
00:01:01,330 --> 00:01:07,200
will help you understand how things works behind the scenes and that will make you a better programmer.

14
00:01:07,210 --> 00:01:08,710
So let's start.

15
00:01:10,770 --> 00:01:12,350
This is with pie charm.

16
00:01:12,420 --> 00:01:19,800
This folder that's just got populated with these two folders, the van folder which contains the virtual

17
00:01:19,800 --> 00:01:20,550
environment.

18
00:01:20,820 --> 00:01:25,920
I've already explained what virtual environments are, but I'll talk about that again in this video.

19
00:01:26,340 --> 00:01:33,840
And then in this folder we also have this dot idea folder which contains configuration files about this

20
00:01:33,840 --> 00:01:35,220
part term project.

21
00:01:35,220 --> 00:01:38,610
So these are related to the actual project ID.

22
00:01:39,360 --> 00:01:44,850
Now I also have this without pie folder in here, which is empty.

23
00:01:44,880 --> 00:01:50,040
Now I want to start a new app in this folder.

24
00:01:50,040 --> 00:01:51,720
So how do you do that?

25
00:01:52,290 --> 00:02:01,430
Well, starting a new app implies that you need three things, so you need to create that P files.

26
00:02:01,440 --> 00:02:06,330
You need a text editor to edit those plus P files.

27
00:02:06,330 --> 00:02:11,190
And third, you need a python interpreter to run those dot PY files.

28
00:02:12,060 --> 00:02:15,780
When we use an ID, all of that is taken care of by the ID.

29
00:02:15,810 --> 00:02:21,960
But now let's see how we can get everything together to be able to code a program.

30
00:02:22,740 --> 00:02:29,190
So the first thing you do out of these three is you take care of the python interpreter.

31
00:02:29,310 --> 00:02:36,810
So it's a good idea to create a virtual environment and use the interpreter of that virtual environment

32
00:02:36,810 --> 00:02:43,500
instead of using the interpreter you have installed globally in all your operating system.

33
00:02:44,130 --> 00:02:46,820
So let's create a virtual environment first.

34
00:02:46,830 --> 00:02:54,360
For that, you need to right click over that folder and go to open in terminal on Mac that could be

35
00:02:54,360 --> 00:02:57,750
hidden somewhere under more services.

36
00:02:57,750 --> 00:03:03,630
And then there will you'll see open new terminal or something like that.

37
00:03:03,780 --> 00:03:05,160
So if you do that.

38
00:03:10,940 --> 00:03:16,760
Now the terminal app here is pointing to this directory, so that's the current directory.

39
00:03:16,940 --> 00:03:26,030
And here I can create a virtual environment using the command p y -3.11.

40
00:03:27,720 --> 00:03:37,110
If you are on Mac or Linux, that should be Python 3.11 without spaces, but you might also want to

41
00:03:37,110 --> 00:03:38,970
change the version to something else.

42
00:03:38,970 --> 00:03:39,830
Whatever you have.

43
00:03:39,840 --> 00:03:40,500
13.

44
00:03:40,500 --> 00:03:41,190
14.

45
00:03:43,260 --> 00:03:45,300
So I am on a Windows currently.

46
00:03:45,300 --> 00:03:48,810
So that would be P space minus three points 11.

47
00:03:48,930 --> 00:03:51,870
So please make sure to have the actual version here.

48
00:03:52,110 --> 00:03:55,800
3.11 In my case then you have an MX flag.

49
00:03:56,830 --> 00:04:04,750
The RM flag allows you to access Python libraries then is one of the Python libraries standard Python

50
00:04:04,750 --> 00:04:05,560
libraries.

51
00:04:06,190 --> 00:04:13,810
So just like we have other Python libraries which we import inside a Python script, this is also a

52
00:04:13,810 --> 00:04:18,810
library, but in this case we are using it in another way.

53
00:04:18,820 --> 00:04:26,140
So this library now will create a folder named End or Python likes to call it.

54
00:04:26,920 --> 00:04:30,880
So as you see here, Python created this event folder.

55
00:04:32,050 --> 00:04:34,500
Which you can also see inside this folder.

56
00:04:35,110 --> 00:04:40,810
So that's the same directory and that same folder is what we will create now.

57
00:04:40,810 --> 00:04:43,180
But in this other folder.

58
00:04:46,410 --> 00:04:55,390
So if you press enter now, what will happen is that inside this folder, a vent folder will be generated.

59
00:04:55,410 --> 00:04:56,790
So let's check that.

60
00:04:57,430 --> 00:04:58,470
Yeah, here we go.

61
00:05:00,000 --> 00:05:06,540
And if you go to the scripts folder on Mac and Linux, that should be named Bin.

62
00:05:06,540 --> 00:05:10,350
So go to the bin folder on Mac or Linux scripts on Windows.

63
00:05:10,620 --> 00:05:12,840
And here you should see Python.

64
00:05:13,290 --> 00:05:18,930
So that's the interpreter we should use for running the files of this project.

65
00:05:19,740 --> 00:05:21,750
So to create files then.

66
00:05:22,640 --> 00:05:23,960
There are two ways.

67
00:05:23,960 --> 00:05:32,570
You either create the files from the command line from here, if you prefer using commands, or you

68
00:05:32,570 --> 00:05:36,760
can create the files using the file system.

69
00:05:36,770 --> 00:05:44,030
For example, you can right click here, go to new and go to text documents and write something like

70
00:05:44,030 --> 00:05:45,830
main that p y.

71
00:05:46,820 --> 00:05:54,080
On Mac, you probably need to use the terminal using the command touch main dot P because on Mac is

72
00:05:54,080 --> 00:05:56,840
not easy to create new text files.

73
00:05:57,140 --> 00:06:06,500
Now note that even though we named this file that P on Windows, this still has a dot txt extension.

74
00:06:06,500 --> 00:06:14,150
So technically this is main that p dot txt but windows is hiding that txt extension.

75
00:06:14,150 --> 00:06:16,430
To fix that you want to go here.

76
00:06:17,300 --> 00:06:18,940
And then go to options.

77
00:06:18,950 --> 00:06:26,720
So go to file and folder options and then you want to go to view and then you want to uncheck this option.

78
00:06:26,720 --> 00:06:30,680
Hide extensions for known file types apply.

79
00:06:30,680 --> 00:06:31,340
Okay.

80
00:06:31,340 --> 00:06:35,480
And now Windows is revealing the truth here.

81
00:06:35,480 --> 00:06:39,470
So it's telling us that this does actually have a TXT extension.

82
00:06:39,470 --> 00:06:46,010
So rename the file to main that spy the next you want to start coding.

83
00:06:46,010 --> 00:06:51,620
So we you might use any editor that you like.

84
00:06:57,830 --> 00:07:00,420
So you could use Notepad on Windows text.

85
00:07:00,440 --> 00:07:01,700
Edit on Mac.

86
00:07:02,300 --> 00:07:05,180
I'm just picking in a simple editor here.

87
00:07:06,440 --> 00:07:09,710
Then here you can start coding like that.

88
00:07:09,860 --> 00:07:17,420
Of course, as you can see, this doesn't have syntax highlighting, so you're coding in the dark,

89
00:07:17,630 --> 00:07:18,680
so to say.

90
00:07:18,770 --> 00:07:25,100
And this is how things were in the past when modern ideas didn't exist.

91
00:07:25,640 --> 00:07:27,680
So I can save this file.

92
00:07:29,030 --> 00:07:30,260
I want to run it.

93
00:07:30,680 --> 00:07:32,960
Go to the terminal again.

94
00:07:32,990 --> 00:07:37,250
If you close it, you should go back in here and open it again.

95
00:07:37,400 --> 00:07:40,170
And then to run the file.

96
00:07:40,190 --> 00:07:41,330
Now you have two options.

97
00:07:41,330 --> 00:07:49,460
You can either run it with your main python interpreter, your global interpreter, or using your virtual

98
00:07:49,460 --> 00:07:50,750
environment python.

99
00:07:51,290 --> 00:07:54,170
So of course, the second option makes more sense.

100
00:07:54,170 --> 00:07:57,470
You should use the python of your virtual environment.

101
00:07:59,020 --> 00:08:04,810
That's better because it keeps this interpreter only for this project.

102
00:08:04,810 --> 00:08:11,830
So if you install, for example, libraries, third party libraries for this particular python interpreter,

103
00:08:11,830 --> 00:08:15,160
then these libraries will be only for this interpreter.

104
00:08:15,250 --> 00:08:18,640
They will not be installed for your global python interpreter.

105
00:08:19,480 --> 00:08:29,500
So to run the main that speaker file using the virtual python you do then slash on Mac or Linux.

106
00:08:30,410 --> 00:08:33,309
On windows that would be a backslash.

107
00:08:33,320 --> 00:08:44,059
And then on Windows you'd write scripts on Mac that would be been on Linux, it would also be Bin and

108
00:08:44,059 --> 00:08:47,360
then slash again and then you access Python.

109
00:08:48,440 --> 00:08:50,360
So we are accessing.

110
00:08:53,470 --> 00:08:56,140
From vendors and scripts.

111
00:08:57,170 --> 00:08:59,150
This python file.

112
00:09:01,120 --> 00:09:04,840
And then you point to your main dot p one file.

113
00:09:05,530 --> 00:09:09,160
So make sure, of course you are inside without power charm.

114
00:09:10,540 --> 00:09:12,550
Otherwise this will not work.

115
00:09:13,180 --> 00:09:17,560
So we are running that file using that python interpreter.

116
00:09:18,070 --> 00:09:19,690
So execute that and we get.

117
00:09:19,690 --> 00:09:20,110
Hello.

118
00:09:20,230 --> 00:09:21,310
That's the output.

119
00:09:22,380 --> 00:09:27,600
And that's how you code an app without using an I.D..

120
00:09:27,720 --> 00:09:30,630
That's the manual thing of doing coding.

121
00:09:31,140 --> 00:09:41,250
So when you execute an app in point charm using that triangle button, what we do is we call that particular

122
00:09:41,250 --> 00:09:42,290
command.

123
00:09:42,300 --> 00:09:49,680
So we start the interpreter, the virtual environment interpreter, and we interpret that file using

124
00:09:49,680 --> 00:09:52,830
that interpreter, and we get the output in here.

125
00:09:54,050 --> 00:10:00,530
Now, sometimes what happens is that when you open an existing project in term.

126
00:10:02,140 --> 00:10:03,550
Any project.

127
00:10:07,170 --> 00:10:15,000
Sometimes Pine Shire may not recognize the virtual environment immediately and you'll get probably a

128
00:10:15,000 --> 00:10:22,540
message here which tells you that you should specify an interpreter, so you might click that interpreter.

129
00:10:22,560 --> 00:10:33,750
Path the path that Pachachi is suggesting you or you have to go to the settings in here and then go

130
00:10:33,750 --> 00:10:36,390
to projects and then go to Python.

131
00:10:36,450 --> 00:10:42,420
Interpreter And then you might have to add a new interpreter by using this button here.

132
00:10:42,420 --> 00:10:43,050
Add.

133
00:10:45,330 --> 00:10:50,910
And sometimes pie charts may tell you that, Oh, this directory is not empty.

134
00:10:51,090 --> 00:10:59,340
So in that case, you should go to this folder in your file system and delete the existing vent folder,

135
00:10:59,340 --> 00:11:04,500
which is problematic, and it's causing you these messages.

136
00:11:04,500 --> 00:11:07,970
And then this message will not show here anymore.

137
00:11:07,980 --> 00:11:15,120
So you can press okay to create a new virtual environment if the previous one is having issues.

138
00:11:15,930 --> 00:11:18,180
So that was just the tip about punch.

139
00:11:19,140 --> 00:11:21,420
And thanks for following this.

140
00:11:21,450 --> 00:11:22,230
I'll see you later.

