ANACONDA Tutorial for Python | How to Install Anaconda on Mac OS and How to use Anaconda for Python

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys i'm tawfiq and in this video let us understand how to use anaconda for python now i'm going to start this video by giving you an intro of what anaconda is and why you should be using it we'll then see how to install anaconda and how to use anaconda we'll then see how to create different virtual environments using conda and also see how to connect to different virtual environments from visual studio code now if you are only interested in watching the installation and how to use anaconda then i'll leave a timestamp to each of the different sections in the description below so you can only watch the sections that you are interested in again before i can start if you like this video then please make sure to subscribe to the channel and give me a thumbs up thank you and let's begin when i started learning python i did not use anaconda for a very long time and the simplest reason for that was i just did not understand what is anaconda it was very confusing for me as a beginner to know why do we need to use anaconda and what are the benefits of using anaconda it was only when i started building projects i realized the benefits of using anaconda so what is anaconda anaconda is simply a python distribution meaning when you install anaconda it will not only install python but along with python it will also install a few other softwares as well which are compatible with python and very useful especially if you are working in the field of data science so when you install anaconda it will install python of course but along with python it will also install a lot of other packages which are very useful and widely used in the field of data science so you don't really have to install each of the data science packages one by one everything will be bundled together with anaconda installation now along with all of these additional packages anaconda builds also comes with condom conda is a package manager which is similar to pip so contact can be used to install any additional packages that you may need along with that contact can also be used to create virtual environments and manage virtual environments so along with conda and all of these additional packages anaconda also comes along with a few tools such as an ide called spider and it also comes with jupiter notebook and a few other tools as well so in general anaconda is simply a bundle package which comes along with python and all the other tools and software that you would need to work with python especially in the field of data science now if you're someone who is wondering that you don't really need to use all of these additional software's tools and packages then of course you can just install python as a standalone software and you would not have any issues so it's not mandatory that you need anaconda to work with python it's just that by using anaconda it makes it much more convenient to work with python especially in the field of data science now one of the best use cases that i can think of of using anaconda is how easy it is and convenient it is to create virtual environments using condom now of course we can create virtual environments without conda as well by using the venv module in python but i think conda is more convenient so let's say you're working on two different projects where each of these projects require a different version of python to be installed and also you need a different version of a particular package to be installed in each of these projects then if you are not going to create virtual environments then you basically would need either two different computers to work on each of these projects simultaneously or you would need let's say creating multiple different users in the same computer to work on two different projects since you need different versions of python as well as different versions of a particular package so to avoid this the best solution would be to create virtual environments and conda makes it very easy to create and manage virtual environments i hope this gave you some information about what anaconda is and why we should be using it now let's see how to install it and let's try to use it okay so before i can install anaconda there are a couple of things that i want to mention that is if you have installed python already in your machine then it is okay you don't really need to uninstall it for example in my machine i already have python 3 installed so i can check that by saying python 3 dash 3-version and it will show me that python 3.9.6 version is already installed on my machine and now if i run the command conda you can see that anaconda is currently not available it's okay if you have python already installed you can still go ahead and install anaconda and then you will still be able to use the python that comes along with your anaconda installation the second thing is if i go to my visual studio code currently if i click on the python interpreter at the bottom left here you will see it will show me all the different versions of python that are currently available in my machine so once we install anaconda you will a visual studio code will then be able to recognize the python versions that came along with anaconda okay so we'll see that in a bit now let's go ahead and install anaconda so to install anaconda i just need to go to my browser and type anaconda and you should see something like anaconda.com just go to anaconda.com which is the official anaconda website and then go to products and click on individual edition and here you would find a download link depending on your operating system it would show the download link specific to your operating system so just click on download and then click on save and you can ignore this anaconda nucleus i'm just going to close that so the download is complete i'm just going to click on this file and i'll close my browser and i'm going to say allow and then it's just a simple installation so i'm just going to click continue continue continue agree and then instead of installing anaconda or for a particular user i'm going to install it for my entire system that is the macintosh hd and i'll just choose this and i'll click continue and i'll say install it will ask me for my password so this might take a few minutes to complete so we'll just wait for that okay just click ok ok so the installation is complete now if you want to install pycharm you can just click on this link and you will have to install pycharm separately but i don't want to do that so i'm just going to say continue and you can see that installation is completed successfully so i'm just going to close this and move this to bin now in order to verify your installation you can just go to terminal and then you can already see that we have something like base which basically is the default anaconda environment now if i type the command like conda you can see that it shows us all the different commands that are available with conda so this basically means that then account installation was successful now when you install anaconda it also will install a graphical user interface that you can see here in your application section so if i just click on that anaconda navigator this is where you would see all the different tools and software that came along with anaconda so we can see that we have jupyter notebook jupiter lab we have spider and you can also see that we have vs code now this vs code is showing up here because i already have vs code installed on my machine prior to anaconda so that is why anaconda is able to identify that now let's say if you did not have vs code already installed then you would basically not see this option so this is basically all the different tools and if i go to environments you would see that all the different environments that you have created the base environment is the default environment that comes along with anaconda and it also shows all the different packages that are available within this particular environment if you create a different environment or a different virtual environment then you would see that list here and all the related packages you would see it here and also you have something like learning where you would find documentations to different libraries uh which you can definitely read so this is what basically anaconda navigator has i'm not going to use it for now so i'll just close this now back to my terminal let me just clear this and let me run a command like conda list and this will show me all the different packages that came along with anaconda installation and these packages are available in my base environment now if i wanted to identify the version of python that was installed on this environment then i can just run the command like python 3 dash dash version and you would see that i have the python version like 3.8.8 okay so let's say if i wanted to deactivate or move out of the anaconda based environment then i can just run the command like conda deactivate and this would just move back to my original terminal without the anaconda environment okay and here if i run that same command that is python 3 dash dash version you would see i have python 3.9.6 so this is the python version that is without anaconda of course we are going to use anaconda so i'm just going to say activate base so this is basically how you can go back to the python base environment okay now let's go back to visual studio code and see how we can run programs by using the anaconda python environment okay now if i click on the python interpreter you would see that i cannot see the list of anaconda environment here so what i basically need to do is i need to restart visual studio code so i closed it and now i'm going to open it again and let me open the same file so i'll just go here open folder and i'll choose demo and i have this file if i click on the python interpreter now now you can see that visual studio code is able to recognize that we have installed anaconda and anaconda comes with this base environment and it's already showing us an option here so if i choose this option that is the base conda environment now this program will run on this particular conda environment okay and which uses the python version as python 3.8.8 so this is basically how we can change uh different environments now one thing i quickly want to show here is so i'll go back to my older python version and here if i try to import a module like let's say pandas okay so i did not have pandas that came along with my standalone python installation and if i try to run this it's going to throw me an error saying that no module named pandas okay but if i choose the contact-based environment as my interpreter and then if i try to run this program this one works fine and the reason is the anaconda based environment not just installed python but it also installed a lot of other packages and pandas is one of them so this is basically the difference if you install standalone python it only installs python and it hardly has any additional packages but with anaconda there are a lot of packages that are pre-installed so that is why we are able to import pandas straight away using the conda based environment now this is fine but let's say if i was working on two different projects let's say one project related to machine learning and another project related to data science what i would generally do is i would create different virtual environment for each of my projects so let's see how we can do that so i'll just go back to my terminal and here in order to list down all the different environments available i can just say conda env list currently we only have one environment that is a default base anaconda environment and that is what you see here now in order to create a virtual environment i can just run the command like condom create dash dash name and then provide a virtual environment name so for my machine learning project i'm just going to name the environment like ml env and i'm going to say that i need the python version to be let's say 3.7 so i'll click yes and this has basically created a virtual environment by the name ml env now similarly i'm going to create another virtual environment for my data science project i'm going to call it like say contact create dash dash name and call it like ds env and the python version i want here is let's say 3.9 and again i'll say yes okay so we have created two virtual environments now let's try to work with these virtual environments but before that let me just see the list of all my environments so currently i would have three environments so base is the default environment then i created ds env to perform my data science project and i created ml env this is where i will be doing my machine learning project okay so if i go back to my visual studio code now and if i click on the interpreter visual studio code is not able to recognize this virtual environment that i just created so again you need to restart visual studio code so i'm just going to close it and open it again and again i'll just choose my program and now if i click on the python interpreter you would see that it's showing me the list of the two new virtual environments that i just created the ds env and then the ml env so in order to clearly understand how to work with different virtual environments let's say i'm going to click on the interpreter to be my mlenv environment currently this environment does not have the module pandas so if i click and run it will throw me an error saying that no module name pandas and that is because if i go back to my terminal so the base environment had a list of so many packages but when we created the virtual environment it's not going to inherit all the packages from the base environment so if you wanted a specific package you still needed to install it in each of your virtual environments so let's say for my machine learning project i need a particular package that is scikit-learn i'm going to install it so first we need to activate the machine learning environment so i can do that by saying honda activate ml env and you can see that now from base it has now changed to ml enb meaning that we are currently activated on the machine learning environment virtual environment so here i'm going to install a package let's say conda install and the package name would be scikit learn i'm going to say yes okay so it is done so i have installed scikit-learn package in my machine learning environment because i need to use this package only in this particular project now let me go back to my data science environment so i'll say conda activate ds env so let me just clear this and here i want to create or install a package by the name let's say c bond so i'll say condom install c bond so this c bond is generally used for data visualization and i'm going to use this only for my data science project so i'm just installing this particular package only under my ds env virtual environment okay so the package has been installed now let's see how we can work on different projects by using visual studio code but before anything let me just restart vs code and and i'm currently in my machine learning environment you can see that you can choose whatever environment you want so i'll just choose machine learning and here i want to use the package that i just installed that is sklearn so now you can see that sk learn if i run this program it should basically work fine okay so it's basically working fine so i was able to import the sklen so the package when you try to import we call it like sklearn but when i try to install we save like cyclic lamp so but they both are the same so let me just close this and let's go back to my data science environment now that is dsenb and here if i try to import the sklearn and if i try to run this it's going to throw me an error saying that no module named sqlm so what this means is i installed the sklen or scikit-learn only in my machine learning environment if i try to access that package from a different virtual environment then i will not be able to do that so this is basically how you can isolate different projects by having them work upon using a specific virtual environment okay now let's say if i go back to my ds env environment and here instead of sklearn if i try to import cbone which is what i created and if i try to run this program it should basically work fine and yes it works fine so this is basically how we can work with different virtual environments by just changing the interpreter to whatever environment you want visual studio code to point to now the last thing that i want to talk about is channels so if i go back to my terminal you can see i have currently three different environments but let's say i was working on a new project which is to analyze the youtube data so what i'm going to do is first i'm going to create a virtual environment by the name let's say condom create dash dash name i'm going to call this like youtube yt env and the python version that i need to use here is let's say 3.9 okay so why have created this environment or new virtual environment is i want to work on a new project where i want to extract data from youtube now in order to extract data from youtube i need to access an api and also i need access to a particular package so let me just clear this and again let me just see the env list so in order to access the youtube data i need to install a package so first thing i need to do is i need to go into my youtube virtual environment i can do that by saying condom activate yt env and from here i need to install a package by the name let's say conda install and the package name is google api python dash client okay and now you can see that it's actually throwing me an error saying that package not found error the following package are not available in the current channels now the problem is the package that i was trying to install is currently not recognized by anaconda when you try to install a package anaconda will look in the default channels that is the channels that are mentioned here channels are simply a url or a repository where anaconda has basically stored all the different packages so if a package is available in this channels or in this url then anaconda will be able to install it but if you try to install a package which is not present in this particular url or in this channel then anaconda will not be able to install it now to overcome this issue what we can do is we can either install a particular package from a channel where it is present or we can add a channel to the list of channels that are available in anaconda and that is what we are going to do now now i already know that this particular package is present in a channel called conda forge so i'm just going to add this channel conda forge into my list of channels in anaconda and then i'm going to try to install this package again okay now before i can do that let me show you a list of all the channels that are currently available so i can just say condom config dash dash show and then i can say channels this will show all the different channels currently by default you would only have one channel by the name defaults and to add a new channel i'm just going to say conda config dash dash add and i'll say channels and then you need to provide the channel name so i'm just going to use conda forge and i'll just run it and the channel has been added now if i run the show channels command you can see that we have two different channels now along with this i also want to show you another command so let's say instead of show if i just type get what this will show me is it will show me the list of channels and it also tells me the priority so meaning that when i try to install a new package it will first look for in the channel which has higher priority so it will first look in the conda forge channel and if that package is available in this contact for channel then it will install it from here if it is not present here then it will go and look into the default channel and try to find that package there okay so we have added our channel now what we will do is we'll try to install the package that is the google api package so i'm just going to say conda install okay so the package was created so now if i just go back to my visual studio code and click on the interpreter okay i do not see this new yt env environment here so let me just restart vs code and i have my program here so let me close the notification and let me change the environment to now the youtube environment and here i want to import the package that i just installed which will be imported as google api client and you can see it works absolutely fine so this is basically how we can install packages that may not be present in the default channel and you will have to add your own channel and then you will be able to still install it i hope all of this was clear you got an idea of how to work with different channels by just changing the interpreter in visual studio code and i believe whether you are using any other ide the process would almost be the same you just need to change the interpreter to point to the particular anaconda environment and then you can just work on the project as usual thank you and see you soon in the next one bye
Info
Channel: techTFQ
Views: 2,210
Rating: undefined out of 5
Keywords: Anaconda Tutorial for Python, How to Install Anaconda and How to use Anaconda for Python, How to install Anaconda for Python, How to use Anaconda for Python, Why do we need Anaconda, anaconda for python, python anaconda, anaconda python tutorial, python anaconda tutorial, anaconda tutorial, install anaconda, install anaconda mac, How to Install Anaconda on Mac OS, how to install anaconda on mac, how to install anaconda, anaconda installation, python tutorial
Id: 0Hhqf8L-b_0
Channel Id: undefined
Length: 19min 57sec (1197 seconds)
Published: Tue Sep 21 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.