1
00:00:05,320 --> 00:00:10,630
In this video, we want to configure IntelliJ IDEA
so that we can actually start some Python coding.

2
00:00:10,990 --> 00:00:12,620
If you decided to install PyCharm

3
00:00:12,640 --> 00:00:18,070
instead, you can skip this first step. But keep watching,
because the steps after installing the Python

4
00:00:18,070 --> 00:00:20,390
plugin are also applicable to PyCharm.

5
00:00:21,070 --> 00:00:22,930
So what we want to do is two things.

6
00:00:23,350 --> 00:00:26,410
Firstly, we need to download and install a plugin for Python.

7
00:00:26,740 --> 00:00:32,500
And secondly, we need to associate the Python install,
that we've done previously in the course, to

8
00:00:32,500 --> 00:00:35,680
IntelliJ IDEA, so that they actually work together.

9
00:00:36,310 --> 00:00:39,790
So let's start with the plugin.
On the welcome screen of IntelliJ IDEA,

10
00:00:39,940 --> 00:00:41,680
come over here to the left,
and click on Plugins.

11
00:00:42,460 --> 00:00:43,660
Now there's two tabs here.

12
00:00:44,050 --> 00:00:47,860
The Installed tab, if I click that,
shows which plugins you've got installed.

13
00:00:48,240 --> 00:00:52,240
There are quite a few that are already
installed, but Python isn't one of them.

14
00:00:52,790 --> 00:00:54,320
So click the Marketplace tab.

15
00:00:55,000 --> 00:00:56,920
This shows us all the plugins that are available.

16
00:00:57,460 --> 00:01:01,090
When you've been programming for a while, you'll
more than likely find some useful ones here.

17
00:01:01,600 --> 00:01:05,770
But we're just starting, and all we need
is the Python Community Edition plugin.

18
00:01:06,160 --> 00:01:10,240
So rather than scrolling through the list,
type python in this search box.

19
00:01:11,860 --> 00:01:14,140
Make sure you spell it correctly,
otherwise it won't be found.

20
00:01:14,890 --> 00:01:18,680
The one we want is probably right at the top,
the Python Community Edition.

21
00:01:18,800 --> 00:01:20,170
And you can see that is the case here.

22
00:01:20,720 --> 00:01:23,220
Come up here and click on
Install to install it.

23
00:01:24,270 --> 00:01:27,570
Now, if you get a privacy note, read it
if you want, and click Accept.

24
00:01:29,210 --> 00:01:32,920
Now, whenever you install or update a plugin,
you have to restart IntelliJ.

25
00:01:33,320 --> 00:01:38,000
So I'm going to click on the Restart IDE button,
and confirm that by clicking on Restart.

26
00:01:42,220 --> 00:01:47,320
All right, so IntelliJ's restarted. We've now
installed the plugin for Python, and we can proceed

27
00:01:47,320 --> 00:01:49,320
to setting up the Python SDK.

28
00:01:49,750 --> 00:01:54,240
Basically, that means telling IntelliJ
where Python is installed on the computer.

29
00:01:56,350 --> 00:02:02,680
So think of a software Development Kit, or SDK, as the
tools you need to write programs. The Python SDK

30
00:02:02,920 --> 00:02:06,550
includes an interpreter, that can understand
your Python code and execute it.

31
00:02:07,060 --> 00:02:13,320
It also has a debugger, and we'll be seeing what that is,
and how to use it, when we've written a program to debug.

32
00:02:13,330 --> 00:02:18,790
An SDK can also include useful modules, that
you can include in your own code. For Python,

33
00:02:19,000 --> 00:02:24,100
These modules are in the Python Standard Library.
We'll be using quite a few modules from the standard

34
00:02:24,100 --> 00:02:26,860
library, to let our programs
do some cool things.

35
00:02:28,980 --> 00:02:34,170
You can set up SDKs for different versions of Python.
That can be very useful, once you've written

36
00:02:34,170 --> 00:02:37,680
your program, to make sure it works
with all the versions that you support.

37
00:02:38,130 --> 00:02:42,990
You've probably installed Python 3.9,
which was the latest version at the time

38
00:02:42,990 --> 00:02:44,290
I'm rerecording this video.

39
00:02:44,700 --> 00:02:48,120
It's generally not a good idea to
use your main Python installation.

40
00:02:48,750 --> 00:02:54,330
If you install an incompatible package into the
main Python installation, you can end up with problems.

41
00:02:54,930 --> 00:02:58,180
The only solution, in that case,
is to reinstall Python.

42
00:02:58,380 --> 00:03:04,680
A better approach is to create a Python virtual
environment, or virtualenv or even venv, if you

43
00:03:04,680 --> 00:03:06,690
really like abbreviating
things to extremes.

44
00:03:08,780 --> 00:03:12,800
To create our virtual environment,
we need to create a new project first.

45
00:03:13,610 --> 00:03:18,230
At the moment, when Projects is selected,
to the left, there's three buttons available.

46
00:03:18,740 --> 00:03:22,500
New Project is used to create a new project,
which is the one we'll use shortly.

47
00:03:22,500 --> 00:03:28,040
Open will let you open a project that you created earlier,
so that you can continue working with it.

48
00:03:28,820 --> 00:03:34,760
If you use a version control system, such as git,
the Get from VCS button will fetch a project from

49
00:03:34,760 --> 00:03:37,220
your version control system.
Hence VCS.

50
00:03:37,700 --> 00:03:42,430
But don't worry, if you don't know what a VCS is, you won't
be using one until you've been programming for a little while.

51
00:03:43,000 --> 00:03:44,720
For now, though, click on
the New Project button.

52
00:03:45,780 --> 00:03:50,400
The New Project dialogue, which has popped up, lets
you choose which programming language you want to use.

53
00:03:50,880 --> 00:03:54,660
This is a Python course, so we're going
to choose Python on the left hand side.

54
00:03:55,140 --> 00:04:00,180
If you don't see Python there, make sure you've
installed the Python plugin, and also make sure you

55
00:04:00,180 --> 00:04:04,470
restarted IntelliJ after you installed the plugin.
Alright, so select Python.

56
00:04:05,900 --> 00:04:12,740
And you see that the right hand pane changed. It's now
asking us to specify a Project SDK, and shows us

57
00:04:12,740 --> 00:04:18,800
that we don't have one. That's fine because when you click
the dropdown box, there's an option to Add Python SDK.

58
00:04:19,160 --> 00:04:25,280
And also note that IntelliJ helpfully detected
the SDK installation, the Python installation from

59
00:04:25,280 --> 00:04:26,020
an earlier video.

60
00:04:26,540 --> 00:04:31,130
But just in case it hasn't selected that, I'm
going to click on Python SDK to show you what happens.

61
00:04:32,060 --> 00:04:35,510
We're now on the screen that lets
you set up your Python SDK.

62
00:04:36,080 --> 00:04:38,510
Now, don't worry too much about
the four options on the left.

63
00:04:38,850 --> 00:04:41,110
We're going to create a
Virtual Environment.

64
00:04:41,270 --> 00:04:47,090
So make sure that's selected. If you decided to use
Anaconda, instead of the Python version that I installed

65
00:04:47,090 --> 00:04:52,220
earlier, then you should select Conda Environment.
But most students should use Virtual Environment.

66
00:04:52,920 --> 00:04:55,850
So over to the right, we want to
create a New environment.

67
00:04:56,420 --> 00:05:00,970
This will basically be a copy of your main Python
installation, the one we installed earlier.

68
00:05:01,520 --> 00:05:07,550
If you mess up this virtual environment, you can delete it
and create a new one, without having to reinstall Python.

69
00:05:07,910 --> 00:05:10,300
The location should be in your
home directory somewhere.

70
00:05:10,550 --> 00:05:16,700
For me, you can say it's suggesting
C:\Users\timbuchalka\venv.

71
00:05:17,150 --> 00:05:20,330
You might want to install Python
3.10, or even a later version,

72
00:05:20,600 --> 00:05:23,930
When it comes out in the future.
Or you might want to use an older version.

73
00:05:24,470 --> 00:05:25,340
For that reason,

74
00:05:25,620 --> 00:05:30,920
I like to indicate the Python version in
the directory name. I'm using Python 3.9.

75
00:05:31,130 --> 00:05:36,110
So I'm going to add a \ in
location, and enter python39.

76
00:05:36,540 --> 00:05:38,300
You can see I've added
that to the end of the path.

77
00:05:39,020 --> 00:05:42,170
Now don't use spaces in your directory
names, because that can cause problems.

78
00:05:42,320 --> 00:05:43,970
Next, we choose the
Base interpreter.

79
00:05:44,180 --> 00:05:48,110
That's the main Python installation,
and IntelliJ should have found it for you.

80
00:05:48,620 --> 00:05:53,690
If you have more than one version of Python installed,
you can use a dropdown to select the correct one.

81
00:05:54,020 --> 00:05:56,210
But in my case Python 3.9 is correct.

82
00:05:57,150 --> 00:06:03,530
You can also use these three dots here, the ellipsis button, on
the right to browse to your python.exe file, if you didn't accept

83
00:06:03,530 --> 00:06:05,870
the default path when you installed Python.

84
00:06:06,500 --> 00:06:07,430
I don't need to do that,

85
00:06:08,740 --> 00:06:12,200
because obviously the Base interpreter
is pointing to the correct location.

86
00:06:12,550 --> 00:06:17,280
Now, most of the time, you'll probably want to
check these two boxes down here: Inherit global site

87
00:06:17,350 --> 00:06:22,320
packages, and Make available to all projects.
Inherit global site packages

88
00:06:22,480 --> 00:06:26,200
lets your virtual environment use
the packages in the main installation.

89
00:06:26,620 --> 00:06:28,360
That's almost always what you want.

90
00:06:28,360 --> 00:06:31,900
Unless you're doing something specialized.
Make available to all projects

91
00:06:31,900 --> 00:06:35,350
lets you use this virtual environment
in all the projects you create.

92
00:06:35,740 --> 00:06:40,090
If you don't tick that box, you'll need to
create a new virtual environment for each project.

93
00:06:40,420 --> 00:06:43,900
That's extra effort, and it's completely
unnecessary for most projects.

94
00:06:44,230 --> 00:06:46,920
Right, so I've checked both of those.
I'm going to click okay.

95
00:06:47,920 --> 00:06:52,240
And IntelliJ's going to set that virtual environment up
for us. And this actually can take a short

96
00:06:52,240 --> 00:06:57,010
while, as the key Python files are copied
to your new virtual environment directory.

97
00:07:01,620 --> 00:07:05,610
All right, so as you can see, that's finished now,
and we ended up back at the previous screen.

98
00:07:05,910 --> 00:07:12,570
But this time we now have a Project SDK.
In future, whenever you create a new project, make sure the

99
00:07:12,570 --> 00:07:15,930
SDK is selected in that Project SDK box.

100
00:07:16,280 --> 00:07:18,020
All right.
So that's the configuration complete.

101
00:07:18,480 --> 00:07:20,570
We're not going to create a new project just yet.

102
00:07:21,330 --> 00:07:25,860
With the earlier version of IntelliJ, it was
possible to set up a virtual environment from the

103
00:07:25,860 --> 00:07:26,580
Welcome screen.

104
00:07:27,030 --> 00:07:31,020
That option has been removed, which is
why we've started to create a project.

105
00:07:31,370 --> 00:07:32,700
We want to click on Cancel now.

106
00:07:33,840 --> 00:07:36,850
And we'll actually create our first
Python project in the next video.

107
00:07:37,200 --> 00:07:40,530
Notice that those three buttons may have
moved to the top of the right hand pane.

108
00:07:40,980 --> 00:07:45,270
The main part of this pane will show you a list
of all the projects you've created, which makes it

109
00:07:45,270 --> 00:07:46,790
much easier to open them again.

110
00:07:47,310 --> 00:07:49,560
But don't get hung up on the
position of those three buttons.

111
00:07:49,860 --> 00:07:52,410
JetBrains moves things
around from time to time.

112
00:07:52,650 --> 00:07:57,060
And you'll see that they're in a slightly different
place, in some of the videos, as you proceed through

113
00:07:57,060 --> 00:07:57,630
this course.

114
00:07:58,080 --> 00:07:58,920
But that doesn't matter.

115
00:07:59,010 --> 00:08:02,610
When you see me click the New Project button,
you know where to find it on your screen.

116
00:08:02,970 --> 00:08:05,730
As I say, it might be in a
different place in the videos.

117
00:08:06,300 --> 00:08:11,130
Okay, so we're all set up and ready to program.
We'll make a start on that in the next section.

