You are on page 1of 5

PROFESSOR: Hi.

Today, we're going to talk about Anaconda.


First, we're going to talk about what is it?
Second, we're going to talk about why
we want to use it for this class for all the projects we're
going to build and the for developing
Python projects in general.
Third, we we're going to walk through some basic operations
of Anaconda, essentially how to use it
to manage virtual environments.
By the end of this video, you should
be able to answer these two questions
and also you should be able to use it
for creating and managing different virtual environments
for your projects.
All right.
Let's jump right into it.
So what is Anaconda?
So here, I'm not going to give you a full description of what
Anaconda is.
You can easily find that online.
But very quickly, you can think of Anaconda
as a combination of two things.
First, it's a tool for managing virtual environments.
And second, it's a collection of popular packages related
to data science and then machine learning.
So Anaconda allows you to quickly install
these packages on different operating system
platforms such as Mac OS, Windows, or Linux.
So that is Anaconda.
So these two concepts will become clearer
as we continue these video.
So let's move on to why we want to use it for this class
and for developing Python projects in general.
In this class, we are going to build
many, many interesting machine learning projects.
So let's say now we start our project 1.

Then for this project, we may need some software packages.


So you may need to process some data.
You may need to manipulate some images
or you may do some complicated calculations.
So let's say project 1, we need package A, package B,
and package C. So by installing these packages,
in a way you are creating a software
environment for your project.
So let's call this environment, environment 1.

And then let's assume this is the computer you


are using for this project.

So because right now you only are working on one project,


you can install these packages globally on your computer
so that all applications on this computer
can have access to these packages.
So that's good.
But let's say after you're finished with project 1,
now you are moving on to project 2.
And let's say now for project 2, you
need a different set of packages.
Let's say now you need a package D, package E, and even package
A but with a different version.
So let's say for project 2, you need a package A 2.0.
But for project 1, you only need package A 1.0.
And these two versions are not compatible.
By saying that, I mean if you upgrade
package A from 1.0 to 2.0, that will break project 1.
So for project 2, in order for project 2 to run successfully,
now you are also creating a software environment
for project 2.
So let's call it environment 2.

So because these two sets of packages


conflict with each other, so if now we
want to work on project 2, we will no longer
be able to work on project 1.
So one thing you can do in order to work on project 2
is to wipe out everything you have configured
and you have installed on your computer for project 1
so that you can work on project 2.
However, in a way, that's not very ideal,
because maybe in the future, you wanted to work on project 1
again.
You want to improve project 1.
But you have already wiped out everything
configured for project 1 so you have to do it all over again.
And that way, it also breaks project 2.
So that's not ideal.
Another way you can do is if you are super rich,
you can maybe buy another computer for project 2.
Now you have a dedicated computer for project 1
and a dedicated computer for project 2.
But obviously, that's not very practical,
because if you're going to work on many, many projects,
you're not going to buy many, many computers
and carry them with you so that you
can switch between projects.

So now, what if there's a tool which


allows us to incorporate all these environments
into a single computer?
So let's say session 2 allows us to install environment
1 on this computer and also the environment 2 on this computer
and also keep them separately so that nothing
can interfere with the other.

So this would be ideal.


And this is exactly what Anaconda can offer.
So now, let's come back to the first two concepts.
So Anaconda is a tool for managing virtual environments.
So now using Anaconda, you can install these two environments
on a single computer separately, and also you
can switch between them very easy.
So that's the first feature of Anaconda.
And the second the feature is it's
a collection of popular packages.
So that means here you can think of from package A
all the way to package E and maybe also
with different versions of packages.
They're all included in Anaconda already for you too easily
install on different operating system platforms.
So that's why we wanted to use the Anaconda for this class
for building your projects and also
for developing Python software projects in general.

So now let's move on to the basic operations of Anaconda.


So I'm going to switch to my laptop,
and I'm going to show you some basic operations of Anaconda.
Now I have switched to my laptop.
I already have Anaconda installed on my laptop.
I'm not going to reinstall it again.
But if you just search Anaconda, Anaconda installation,
you should be able to find this website.
And this is the official website for Anaconda installation.
As you can see here, you can install Anaconda
on Windows, Mac OS, and Linux.
So the installation steps should be straightforward.
So if you have Anaconda successfully installed,
you should be able to run this comment called conda.
So if you do that, you should have these messages.
For example, here is the description
tells you that conda is a tool for managing and deploying
applications, environments, and packages.
So you can think of conda is the command used
to buy Anaconda to do operations related
to virtual environments.
So now let's try to create our first virtual environment
for our project 1.
So we can do that by typing conda create name and give
your environment a name.
So for example, you can name your first environment
as project 1 env.
But here, I'm just going to very simply name it env 1.
So proceeded with yes.
So that's it.
We're already to install our first virtual environment.
And by default, this environment is not activated.
So if we want to activate this environment,
we can execute this comment called conda activate env1.
So now, you can see here we have a string appeared to indicate
that we are in environment 1.
And every environment installed with conda
should have Python installed with it as well.
So let's test it.
So if we type Python, and indeed, we
can see we already have Python installed
within the environment.
And we also have Python 2.

So let's exit Python.


Also now if we want to exit this environment,
we can use this command called conda deactivate.
So let's do it.
Conda deactivate.
So now let's try to move on to create the second environment
for project 2.
So by this time, we want to work with Python 3
instead, because many projects are
going to work with Python 3 instead of Python 2
because Python 2 is going to be duplicated soon in the future.
So now when we create the second environment,
conda create name and name it env2,
I can explicitly tell conda that I want Python 3.
And specifically here, I want Python 3.7.
So let's just do that.

So we have created our second environment.


Let's try to activate it.
Conda activate env2.
And let's try to test the Python version.
So here, we can see we have Python 3 installed
instead of Python 2.
So that's very good.
So we exit Python.
So now say for this project 2, we
want to work with data manipulating
packages called Pandas.
So we can install Pandas very quickly
by typing conda install pandas.
So here actually, this command shows one of the two features
we mentioned before of Anaconda, which
is Anaconda is a collection of popular packages ready to data
science.
So you can think of Pandas along with other many, many packages
have already been included in Anaconda so that we can easily
install them like this on different operating system
platforms.
So we still Pandas.

Yes.

Let's try to test it.


So we go into Python.
And we try to import Pandas.
And we don't get any error message.
So this means we have successfully stored
Pandas in this environment.
So now let's exit Python and exit this environment.
Panda deactivate.
So next, I'm going to show you that the two environments
that we just created, environment 1 and environment 2
are independent from each other.
So in order to show that, I'm going back
to the first environment.
I'm going to conda activate env1.
And then we try to go into Python.
So here, first of all, we can see
we still have Python 2 with env1 instead of Python 3
as of the second environment, env2.
And now if we tried to import Pandas as we did before,
we get an error message.
That means we didn't install Pandas, this package,
in environment 1.
So this tells us that environment 1
and environment 2 truly independent from each other.
So let's try to exit this environment.
So next, I'm going to show you the physical location
of the environment we just created,
because if you created them, they should be stored somewhere
on your computer.
So I'll bring up my home directory.
So as you can see, this is my home directory.
And if you installed Anaconda, it
should have this folder called Anaconda3.
So now Anaconda is in its third version.

So if you go into this folder, you


will see there's another folder called envs.
And if you go to this folder, you
will see these two environments we just created.
So env1, env2.
And if for some reason, if you're
done with these environments, and you want to delete them,
you can do that by executing conda env
remove dash n and then the environment name.
So then we just removed the environment first.
And then we can check in this folder that env1 is gone.
And then we can do this for the second environment also.
And then there, we check for env 2 is gone as well.
So that's the basic operations of Anaconda.
With that said, let's go back to our board.

So in this video, we have talked about what is Anaconda


and why we want to use it for this class
and also for future project development.
And we just walked you through the basic operations of using
Anaconda via the command conda.
And by the way, you don't have to remember
all the commands I just typed, because it's also
difficult for me.
So the way I do it is every time if I need something,
I'll just search it online, say how
to create a conda environment or how
to delete a conda environment.
And every time, I can find those commands quickly online.
So you don't have to remember those commands exactly.
So hopefully by now, you are motivated to use Anaconda
and also you feel you comfortable to use
Anaconda for this class.

You might also like