YTread Logo
YTread Logo

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

Apr 23, 2024
Hello everyone, today we will talk about

anaconda

, which just sounds like a big snake, but is actually a very useful 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 create. Our lives are much easier, let me show you how the first

anaconda

helps us create something called work

environments

. We can consider them as separate rooms in a house, 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, the same happens in work

environments

, an environment can represent the machine learning room where it is very common to install the latest version of Python along with the newest and most modern ones. advanced modules like pytorch, while another environment can represent the game development rule where we plan 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, for later work environments.
anaconda beginners guide for linux and windows   python working environments tutorial
It allows 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 thing is that anaconda helps us change from one around another. others with almost zero effort, so let's see how we can install anaconda and create all kinds of environments with it. Now we'll start with a Linux installation

tutorial

and finish with a Windows one, so stay tuned to navigate to anaconda.com. We will click on products and then on the individual edition below we will click on get additional installers and we will select the version of the file that best suits our system in my case which would be the 64-bit one and we will save this file within our downloads. folder and once the download is complete, we will simply click on this folder icon and copy the file name, right click on the file and then press rename, then of course we will copy the name and Then we can continue and open our terminal.
anaconda beginners guide for linux and windows   python working environments tutorial

More Interesting Facts About,

anaconda beginners guide for linux and windows python working environments tutorial...

We will do this by pressing control alt t and from here we can install this newly downloaded file. We'll just type bash, then root folder, download bar, and then paste the file name. We have just copied, we will press enter and of course we will carefully read the entire Anaconda 3 license agreement because this is very important and once we get to the end of this very long scroll, we will simply type Yes and press enter to confirm it. installation location by pressing Enter one more time and this process may take some time so I recommend that you grab your coffee and 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 congratulations now let's go ahead and create our first work environment.
anaconda beginners guide for linux and windows   python working environments tutorial
We will do this by typing conda create dash dash name and then we will select a name for this environment, in my case I will call it n39 because I am going to install Python 3.9 once we are ready, we will press Enter, we will press and and by the way, if you get an error on this point that says conda can't be found, I don't know. where it is, I'll show you how to solve it in a few seconds, if this resulted in an error, you guys can just fix it by typing source, then root dot bash rc and then you can hit enter, which will take you to the base environment now, since we're not really interested in the base environment, we actually want to access our new environment, we'll just copy this command that anaconda politely provided us, paste it in and press enter boom, our environment is activated, as you can 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.
anaconda beginners guide for linux and windows   python working environments tutorial
We will do this by typing conda install c pi torch pi torch and we will press enter we will confirm with and great, now this took a little longer, but now we have pi torch installed and we can verify that we did indeed install it by typing conda list and this will present us with all the different packages that are installed within nf39. We can see that pytorch is among them. our Python version is also here which is 3.9.7 and we can see all kinds of different dependencies that we've installed along with pytorch, like the cuda toolkit, which we'll talk about in a lot more detail in future videos and it's just a good method to check exactly what packages what libraries we have within a given environment and then we will deactivate our environment by typing conda deactivate and we will continue with creating an additional environment where we can install pygame, so once again we will write conda create name and in this case it will I'll call it m27 because I plan to install Python 2.7 on it and again, the reason we install such an old version of Python is because pygame requires it.
Now let's go ahead and press enter and we'll activate this environment. by typing conda enable n27 and once we are inside our environment we can go ahead and install pygame with conda install dash c cog sai pi game, let's press enter, great, now we have pygame installed and we can go ahead and start

working

with it, but what if we need to delete some kind of module, say pie game? We'll just type conda, delete pie game, yeah and boom, it's gone, our environment is empty again, it just has Python and a bunch of dependencies, this is just for demonstration purposes, now let's go. go ahead and disable our environment actually disable conda and if we can't remember the names of our environments we can simply get a list of all the conda environments that 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 happens if we want to update an old one? Let's go ahead and turn on n39 and we'll try to update pytorch, so we'll type conda. update with torch now, in our case we already have the newest version, but if you are

working

with an older version that needs an update, this should work and if we want to update conda we usually write conda update conduct, but because our terminal is at suggest us a different command, we'll just copy and paste it because our terminal knows boo better and we've also updated conda. Now I will also include a very useful link in the video description.
This would be the anaconda. cheat sheet, which is a very short document that describes all the available commands that conda has to offer. Well, now it's all rainbows and butterflies when I provide you with the installation commands, but how would you find these commands independently? Let's say we want to install flask. I'll just do it. type flask conda install and I will navigate to the anaconda.org link where we can find the best installation command at the bottom; however, not all libraries nor all packages are available through anaconda, for example, if we will do the same for sty module we see that there is no anaconda.org link to download this library, we have similar libraries this and this but is not the same, so what we do is navigate to the Python package index where we find the command to install. sty is pip install sty, we will copy it, navigate back to our environment and paste it here, boom, we have sty installed, although we clearly see that we are inside a conda environment, we can still use the pip installation commands, which is amazing because This way we have a kind of backup in case our anaconda command doesn't work, something is not integrated or maybe not updated, we can always use the pip install commands.
Awesome, now another great benefit of anaconda is that it comes with a code editor. called jupyter notebook, you have probably seen me use it a lot in my

tutorial

s and now let's see how we can install it. We can easily install jupyter notebook by typing conda install c anaconda jupiter and then we can open our jupyter notebook by typing jupiter notebook. and as you can see, we're running this notebook locally, this is our computer and this is our file system. Now we can create a new Jupyter notebook by pressing New, in fact, let me expand it because you guys probably don't.
We see it well, so we navigate to a folder of our choice, in my case it would be documents, we will press new and then on Python 3. and that's it, now we can execute our Python commands within this interface, for example, we will print hello world . run this cell with Shift Enter or alternatively we can always press this run button, but I'll 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. I'm still going to click on products and then individual edition, but on this page we're going to click on this download button that my head was blocking before and we're going to click on the executable file that we just downloaded and here we can just follow the wizard instructions we're going to click next we'll click ok we'll install it just for me because it's recommended and then this folder which is probably hard to see because the text is a little small but it says c users maria anaconda 3. this would be In the root folder of our Anaconda installation , we will simply click Next, but as you can see, in my case I already have Anaconda installed, so you cannot create a new folder if it already exists, but in your case, follow the instructions in the wizard. and see you after you install 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 home icon and we'll type Anaconda now. when we see this message from anaconda, anaconda3, we'll just click on it and that's it, that's our terminal, it's a little bit big and here's our beautiful terminal. Now Windows commands are actually a perfect combination with Linux commands, so 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 enter, it will confirm with y and boom, our test environment was created now, the biggest benefit actually, probably the only benefit of using an anaconda terminal instead of the command prompt is that here we can activate this environment without specifying conda, so if we type activate without typos, try me and we will press enter, we are inside the environment already we're not in the base, we're in, try me and we didn't even have to add conda in front of this command, so I don't know if that's a huge benefit, but it's kind of related to the rest of the comments.
You can rewind slightly back to the Linux part of the tutorial and you can apply the exact same Conda commands on Windows now as well. Thank you very much for watching. If you found this tutorial useful, you already know the drill, like it, maybe leave it. send me a comment subscribe to my channel activate the notification bell or share this tutorial with many many many many people thank you again bye

If you have any copyright issue, please Contact