Packages are an important element of software development.
As I mentioned before, this keeps us from reinventing the wheel.
We don't want to waste time on code that has already been
written and problems already solved.
Packages allow us to parse these log files.
Network communication, encryption, oh man,
just think if every time we wanted to hash a file we
would have to roll our own encryption.
Now let's walk through a quick demo demonstrating how to set up
the environment for this course and pulling down some of your
first packages to be imported into Python.
All right, in this demo we're going to walk through a few steps here.
The first and foremost is where to go and find Python, how to install it.
It's probably an important piece for a Python course.
I am on a Windows desktop,
so I'm going to walk through it from that perspective. I'm
also going to use a tool called Visual Studio Code. It is
a free Microsoft download.
I'm going to walk through how to set that up,
get it set up to work with Python. From there,
we're going to talk through where do we get these packages,
libraries that we're going to be talking about in this
course, and then finally how to install them.
So, I am on the python.org website right now. You'll see a Downloads button
here right at the top. There is one item I do want to mention.
So, the yellow Download button will give you the latest version.
If you do click on this Downloads button,
you can then go down to Releases and that will allow you to
go through all the different releases.
So maybe I don't want to install the latest version, maybe I need an
earlier version, maybe I'm working on something for a specific
project that requires an earlier version.
So this will allow me to grab any version that I want
within reason within supported Python download. From
there, once I download the package, I'll kick it off.
So, two items to note on this install package for Python. At the very bottom
you have this checkbox to add Python 3.10 to the path.
It's very important that you check that. You don't
necessarily have to check it, but it makes everything within
Python so much easier if it's there.
So I would definitely look to check that. From there, I'm going
to just use the Install Now button to get this installed fast,
but there is a customized installation where you can check and
uncheck various bits.
One thing you're going to want to leave in there,
especially for this course if you're going to follow along,
is the pip, but everything else is at your discretion if
you want to install it or not.
So I'm going to get this started, and while that's going I'm going to
jump back into my browser and I'm going to head over to Visual Studio
Code. So Visual Studio Code is a nice, free tool Microsoft puts out
there. To download the Visual Studio, you can use the blue button and
just download the latest stable version, which is just the User
Installer version.
If you were to go over to the Downloads page, one thing to note
on here is there is two different versions.
You have the User Installer version and you have the System Installer version.
The biggest difference there is System Installer puts code on the desktop for
everybody to use, all the different users of the system.
The User Installer is just your personal user, so the person who is
currently logged into the system. I highly recommend, especially if
you're not sharing your desktop with anybody else, your laptop, to
use the User Installer.
It does not require admin credentials.
It does not require when you do your updates to have
any type of special privileges.
It puts everything into your local app data path, so I I highly
suggest if you're not needing to have this spread out across multiple
users on this desktop that you simply just install, use the User
Installer and install it that way.
So I'm going to download that, and now I should be able to go back. And my
Python was ready. So Python, as you see there, does have a Disable path
length limit. Not necessary that you have to do that, but it might not be a
bad option for you, just something you need to figure out and determine if
you want to do that for yourself.
So I'm going to close that, and then I'm going to go over to my code
install that I just downloaded. I'm going to accept that, get that
pushed through. Nothing really dramatic with the code. We're going to
wait for this one to finish.
This only takes a few seconds. And at the end of it, I'll be able to
jump into the Visual Studio Code program and I'll walk you through
some additional steps we need there.
So now that I have gotten it started,
I like my dark, and I'm going to just mark this done,
get right in here.
So one of the first things we need to do in order to get Visual Studio
Code to work with Python is we've got to come over to this Extensions
icon here. A building block‑looking icon.
I'm going to open that up. At the search at the top, I'm going to look
for the word Python, and I want to make sure that the Python I'm
selecting is the one that is published by Microsoft. I'm going to hit the
Install button next to that, and that's going to kick off an installation
of Python. And one of the other things you're going to notice, when I
look for the Pylance,
this is kind of like an extension of Python within the Visual Studio
Code. So it's an extension of the extension. That is also kicking
off. And as you can see there, some of the stuff that it adds, but
when it's done, it'll bring you back to your main page. You can close
this extension out.
I do have the ability to look at one of my projects that I'm setting up for
this course, so let's open that up here. On the desktop, I have my Pluralsight,
I'm going to select that folder. So I'm going to be able to see everything
within that folder that I have ready to go.
And one of the tools that we're going to open up is this ps‑psutil.py
One of the things I want to point out is we went through the whole
process of setting up a Python extension in here, and at the bottom
right it shows you that hey, it's using Python, and not only that,
it's using Python 3.10.2.
If I use a shortcut key of Ctrl+Shift+P, it's going to
open up a little search box here, and I'm going to type
in Python: Select Interpreter.
So once I do the Select Interpreter,
you're going to see all the different interpreters that are available to
me for coding in Python. Right after this demo, we're going to get into a
few other interpreters that are out there.
I did make mention that when you're going through the Python download
that you can't select multiple different versions.
So every different version that you install,
you can choose which ones you want to use for this project.
So that's a nice way of jumping between the different versions. But once you
select the interpreter you're going to use, I have some code here. So we can
either open up a command prompt and start to go through and play with this
script that I have open, or you have a little Play button in the top right
corner that opens up a Terminal window.
So after I hit the Play button, it's going to go
through a few steps. And whoops, oh, wait a second,
we don't have the ps‑util library installed.
So what we're going to need to do is open up our terminal window, the Command
Prompt window, and because we installed Python with the pip,
I do have the pip program ready for me.
But first I need to make sure that I have the latest version.
So the first time through you just want to make sure that you
have the latest version of pip on here.
So I'm going to do pip install ‑‑upgrade and then pip.
So what I'm doing here is I'm saying I want to install using pip,
the upgraded version of pip, and it's going to go through and it's going
to get the latest version of my pip installed on here. And when it's
done it's going to come back to the prompt.
So this gives me the latest version of pip, so now I can turn around
and say I want to install that ps‑util library.
So one of the things I want to show you real fast
here if we go back to the browser,
you have this pypi.org site that gives you all the different libraries.
It's basically a repository of all the different libraries and
packages and modules and everything that's available to you in
Python. I'm looking at the pip page right now,
but if we go back to the home page,
I'm able to see everything that's available to me.
I can do a search for any of our packages.
I am going to go back into the pip because there's one
thing I want to show you in there.
So once I'm back in here, on the left‑hand side you have Documentation,
you have download files if you want to fork one of these packages. You can
also install it in different ways, but pip is the way that I'm going to
really show you and play with today.
On the left‑hand side here,
you have the Documentation button. When you click on that, it's going
to take you over to this packaging.python.org site.
We're going to want to look at on here a tutorial for installing the packages.
And about halfway down on that page, you're going to see a
section here where it starts to get into all the different
ways you can use the pip to install.
One of the things I want to point out here is you don't always have to
install the latest version of a library package.
You can simply insert the name of the package in there and it will install it,
but you could also do an equal equal sign and say I want
to install a specific version of a package or I want to
install a compatible version, a version that's older,
any of these different options that you see here.
But one of the things that really is important for you to understand
is you have this information available to you.
This package indexer site is super important. It gives you all the
documentation you may need, how to download it,
where to go for additional information.
But once we jump back to our command prompt,
you'll see I'm just simply doing a pip install the ps‑util. And
now that that's finished, I can jump back into my Visual Studio
Code program and I can run it and I can see that it went through
and completed successfully.
So I'm able to kick off my jobs,
I can see it within this Terminal page here or I can open it up in
Command Prompt and we go through it, but for now that's all we really
wanted to get into at this early stage.