Anaconda Beginners Guide for Linux and Windows - Python Working Environments Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone today we will talk about anaconda which only sounds like a big snake but it is actually a very handy toolkit for python developers now do we have to use anaconda no we can always access python directly from our command prompt however anaconda is here to make our lives much much easier let me show you how first anaconda helps us create something called working environments we can think of them as separate rooms in a house so for example in the kitchen we usually install a sink a bunch of appliances and all kinds of cabinets while in the living room it is very common to see a sofa a television and a coffee table same goes for working environments one environment may represent the machine learning room where it is very common to install the latest version of python along with the newest and most advanced modules such as pytorch this while another environment may represent the game development rule where we are planning to work with pygame which is a very old library so we will also need an older version of python to accommodate it more specifically python 2.7 so then working environments allow us to have multiple versions of python installed on the same computer each environment stores a different version and we can combine it with all kinds of packages that suit it just like choosing furniture and the best part is anaconda helps us switch from one environment to the other with almost zero effort so let's see how we can install anaconda and create all kinds of environments with it now we will begin with a linux installation tutorial and we will end with a windows one so stay tuned so we will navigate to anaconda.com we will click on products and then on the individual edition next we will click on get additional installers and we will select the file version that best suits our system in my case that would be the 64-bit one and we will save this file inside our downloads folder and once the download is complete we will simply click on this folder icon and we will copy the name of the file we will do a right click on the file and then we will press on rename we will then of course copy the name and we can then go ahead and open our terminal we will do this by pressing on control alt t and from here we can install this newly downloaded file we will simply type bash then the root folder slash downloads and then we will paste the name of the file we have just copied we will press on enter and we will of course carefully read the entire license agreement of anaconda 3 because this is so important and once we reach the end of this very long scroll we will simply type yes and press enter we will confirm this installation location by pressing enter once again and this process may take some time so i highly recommend to grab your coffee and to wait about five minutes and once the installation is complete we will simply type yes and then enter so we can initialize anaconda and once we do that we have finally installed anaconda congrats now let's go ahead and create our very first working environment we will do this by typing conda create dash dash name and we will then select a name for this environment in my case i will call it n39 because i'm going to install python 3.9 in it once we are ready we will press on enter we will press on y and by the way if you guys are getting an error at this point saying that conda can't be found i don't know where it is i'll show you how to solve it in a few seconds now if this resulted in an error you guys can simply fix it by typing source then root dot bash rc and then you can press on enter which will get you into the base environment now since we're not really interested in the base environment we actually want to access our new environment we will simply copy this command that anaconda politely provided to us and we will paste it and press enter boom our environment is activated you may notice that instead of the base we are now accessing n39 which is perfect now let's go ahead and install pi torch inside it we will do this by typing conda install c pi torch pi torch and we will press enter we will confirm with y cool now this took a bit more time but now we have pi torch installed and we can double check that we indeed installed it by typing conda list and this will present us with all the different packages that are installed inside nf39 we can see pytorch is among them we can see our version of python is also here which is 3.9.7 and we can see all kinds of different dependencies that we have installed along with pytorch such as the cuda toolkit which we will talk about in much more detail in future videos and it's just a nice method to check exactly which packages which libraries we have inside any given environment and we will then deactivate our environment by typing conda deactivate and we will move on with creating an additional environment where we can install pygame so once again we will type conda create name and in this case i will call it m27 because i'm planning to install python 2.7 in it and again the reason why we install such an old version of python is because pygame requires it now let's go ahead and press enter and we will activate this environment by typing conda activate n27 and once we are inside our environment we can then go ahead and install pygame with conda install dash c cog sai pi game let's press enter awesome so now we have pygame installed and we can go ahead and start working with it but what if we need to remove some kind of module let's say pie game we will simply type conda remove pie game yes and boom it's gone our environment is empty again it only has python and a bunch of dependencies this is just for demonstrational purposes now let's go ahead and deactivate our environment actually conda deactivate and if we can't remember the names of our environments we can simply get a list of all the conda environments we have created on the computer with conda and list boom we can see that we have the base environment we have n27 and we have n39 awesome okay but what if we don't want to install a new package what if we want to update an old one let's go ahead and activate n39 and we will try to update pytorch so we will type conda update by torch now in our case we already have the newest version but if you're working with an older version that needs an update this should do the trick and if we want to update conda we usually type conda update conduct but because our terminal is suggesting us a different command we will simply copy it and we will paste it instead because our terminal knows best boo and we have updated conda as well now i will also include a very handy link in the description of the video now this would be the anaconda cheat sheet which is a very brief document describing all the available commands that conda has to offer okay now it's all rainbows and butterflies when i provide you the installation commands but how would you find these commands independently let's say we want to install flask i will simply type flask conda install and i will navigate to the anaconda.org link where we can find the best installation command at the very bottom however not all the libraries not all the packages are available through anaconda for example if we will do the same for the sty module we see that there is no anaconda.org link to download this library we have similar libraries this one and this one but it is not the same so what we do is we navigate to the python package index where we find that the command to install sty is pip install sty we will copy it we will navigate back to our environment and we will paste it here boom we have sty installed even though we clearly see that we are inside a conda environment we can still use pip install commands which is awesome because this way we have sort of a backup in case that our anaconda command doesn't work something there is not integrated or maybe not updated we can always use the pip install commands awesome now another huge benefit of anaconda is that it comes with a code editor called jupyter notebook you guys have probably seen me using it a lot in my tutorials and now let's see how we can install it we can easily install jupyter notebook by typing conda install c anaconda jupiter and we can then open our jupyter notebook by typing jupiter notebook and as you guys can see we are running this notebook locally this is our computer and this is our file system now we can create a brand new jupyter notebook by pressing on new actually let me enlarge it because you guys don't probably don't see it well so we navigate to a folder of our choice in my case that would be documents we will press on new and then python 3. and there you go we can now run our python commands inside this interface for example print hello world we will run this cell with shift enter or alternatively we can always press on this run button but i will talk about jupyter notebook in much more detail in future tutorials so that was linux however if you are a windows user we will still navigate to anaconda.com we will still press on products and then on the individual edition but on this page we will click on this download button that my head was blocking earlier and we will click on the executable file we have just downloaded and here we can simply follow the instructions of the wizard we will click on next we will click on agree we will install it just for myself because it's recommended and then this folder which is probably hard to see because the text is kind of small but it says c users maria anaconda 3. this would be the root folder of our anaconda installation we'll simply click on next but as you see in my case i already have anaconda installed so it cannot create a brand new folder if it already exists but in your case just keep following the instructions of the wizard and i will see you after you installed it now in the case of windows anaconda is actually a standalone terminal we do not access it directly from the command prompt but we will click on the windows icon sorry on the start icon and we will type anaconda now when we see this anaconda prompt anaconda3 we'll just click on it and there you go that's our terminal it's slightly big and here's our beautiful terminal now the windows commands are actually a perfect match to the linux commands so in order to create a new environment we will type conda create dash dash name we will call it test me and we will install the latest version of python inside it so we will type python equals 3.10 we will press on enter it will confirm with y and boom our test me environment was created now the biggest benefit actually probably the only benefit of using an anaconda terminal instead of the command prompt one is that here we can activate this environment without specifying conda so if we will type activate without typos test me and we will press enter we are inside the environment we are no longer in the base we are inside test me and we didn't even have to add conda in front of this command so i don't know if it's a very big benefit but it's something as to the rest of the comments you can slightly rewind backwards to the linux portion of the tutorial and you can apply the exact same conda commands in windows as well now thank you so much for watching if you found this tutorial helpful you already know the drill please leave it a like maybe leave me a comment subscribe to my channel turn on the notification bell or share this tutorial with many many many many many people thanks again bye-bye
Info
Channel: Python Simplified
Views: 13,772
Rating: undefined out of 5
Keywords: conda, anaconda, anaconda python, conda install
Id: MUZtVEDKXsk
Channel Id: undefined
Length: 14min 38sec (878 seconds)
Published: Tue Nov 09 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.