>> Let's talk about the impact of installing packages.
As we saw in that last slide before we cut over to
this video even with my ink still on and that's just fine.
The way that we install a package just by saying pip
installed and then the name of the package.
Now what's going to wind up happening when we call this is,
it's going to install that package globally.
Which is a good thing and sometimes it's a bad thing.
That the impact of installing that globally means that it
is going to be available for
every application that you are going to be creating,
but the downside is you might be running
into some particular version issues and things like that.
This is also relatively different than
some other package managers such as
New Git or NPM that you might be familiar with,
where in those cases what they're going to wind up
doing is doing a local install of that package.
So it would be available for just your application.
Python does not behave that way.
By default, Python is going to
install all of those packages globally.
So typically as a best practice
what you want to do when you're setting up your application,
is to do a local install and we do that
inside of Python by utilizing a virtual environment.
A virtual environment but quite
simply is literally nothing but a folder
that has all of the code that you're going to
need to run the application that you are creating.
So everything that I need is just going to be installed
into that folder and then I'm able to use it.
Now of course I need to create that folder first,
and we have a little utility called
virtual end that we can use to do exactly that.
Now we will need to install that and the way that we do
that is by saying pip install and then virtual end.
This one we want to do
globally because we're always going to need that.
Then the next step is to create that virtual environment.
Now like I said before,
our virtual environment is nothing but a folder,
that's all there is to it.
So you'll notice in both cases here that I'm just going to
specify the name of the folder that I want to create.
You'll notice by convention most people will just
name it venv short for virtual environment.
You can name it whatever you want, you can call it wibble,
you can call it something
else that might be a little bit more meaningful to you,
it's completely up to you.
Now how you create that is going to vary
slightly depending on the operating system that you're using.
If you're using Windows,
then it's going to be Python,
which we've already seen,
tick m which stands for go grab a particular module,
and then venv which is that shortcut for virtual environment,
and then specify the name of
the folder again that you want to create.
If you're using a Bash shell say
inside of our sacs or inside of Linux,
then it's simply virtual end and then the name of the folder.
That's all that there is to it.
Now when it comes time to use that virtual environment,
then what I need to do is activate it.
You'll notice the syntax to
activate it here and it's going to vary
again depending on your operating system
and also depending on your environment.
That if you're using Windows,
everything that you'll need will be
inside of a sub-folder called scripts,
and then it's always going to be activate,
it's just going to vary on the extension.
Then if you're using a command line
that's going to be a batch file,
if you're using Powershell it's going to be a PS one file,
and if you're using a bash window which
is personally how I generally do things,
then it's just simply activate and then away you go from there.
You will notice a slightly different syntax
up at the very beginning here,
you are going to notice that little dot and then
another space dot and then the path to your folder.
That dot is the location of your source code,
you'll typically do this from the current directory that
is the syntax that you're going to need.
Again I've got placeholders for my folder names,
as we've already discussed.
Typically that will be venv,
but it could be whatever folder name it
is that you have identified.
If you're using OSX or Linux,
then it's the same as before,
what's going to be slightly different is instead of scripts,
it's going to be binned,
that's where you'll find
that activate and then away you go from there.
Now to install into a virtual environment.
After you've activated it,
it's the exact same as doing a global install.
So you'll notice and I honestly just copied
and pasted this slide and changed the title of it,
it's simply pip install and then whatever it is that you want,
if you hover requirements text file then it's pip
install and then net requirements text file.
Okay. There was a lot that was going on there,
and I think the best way to actually
see all of this in action is to start working with it.
So what I want to do is setup
a little demo where it will create a helper's Py file,
show how we can import that.
Then we'll go ahead and create a virtual environment,
we'll install colorama into that virtual environment,
and then we'll go ahead and use
a little bit of colorama in our demo.
So that'll be the next video.