Anaconda Environments - What you need to know.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if you use python to work with data then there's a pretty good chance you use anaconda as your python distribution and that's a very good choice and if you're using anaconda you really need to make sure that you set up environments in anaconda to do that now i've talked about environments before on the channel in this video here but we didn't talk about how to set up environments with anaconda so that's what i'm going to show you how to do today so what is an environment and why do you need them it's really important that you set them up when you first install anaconda you will have a base environment where all your python packages are stored and that works fine but the problem is as you start doing more and more different and varied projects you might find that you need to update the packages that you use for a particular project so you do with project a you start with project a and you install all of the packages and the dependencies that you need for that and then you finish that project and then you start project b in the same environment and that requires different dependencies and different packages so you install those and in doing that you can change the packages that project a relies on and then project a won't work anymore and what the best thing to do is to make each project have its own environment you have a particular environment for a particular project so you don't get any of those conflicts and it's definitely the way to set things up so make sure you do that so i'll show you how to do that now open up your terminal or your anaconda powershell and the first thing we ought to do is just check the version of conda that we have so type in conda hyphen uppercase v and that will give you your version incidentally where you see in brackets here this base that means we're using the base environment at the moment so that's the one that was initially installed and that's the one that we should avoid using so we're going to change that shortly i just wanted to point that out to you let's have a look at what we have in terms of packages installed in this installation here and if we do conda list that will display the packages that this fire environment has installed okay now what about if we wanted to list the environments that we have now i know at the moment you might not have any environments but let's suppose that you had some and you hadn't used them for a while and you just wanted to check and see what you had you can do that by typing conda e n v for environment and then list and here you will see some environments that i've been using recently so here are the ones that i have okay well i think now we're ready to create an environment so let's do that so the way we do that is conda create hyphen hyphen name and then we put the environment name here so let's say we wanted one for data visualization projects that we were doing we'll call it data vis and we now have a an environment it will we will shortly when when it's being created we'll have an environment called dataviz so just wait for that to be created and then you will see this come up and it will say proceed yes or no so you type in y and there we have now a new environment and it tells us the next step actually so if we want to activate this environment so if we want to go into this environment we type conda ack to ev8 and then the name of the environment which is data vis and if we do that now you can see because we have in brackets here before the prompt we have data vis we know now that we're in that environment one thing it's worth noting is that when you set an environment up like this and this is probably the simplest way of setting up an environment because you can there are lots of other ways of of setting up environments and you can specify a particular version of python that you want and you can specify the packages that you want when you set the environment up and you can even choose certain versions of particular packages you can even copy the settings from an environment you're already using so there are lots of more advanced features but this is just the baseline this is sort of the habit that you should get into at the very least this is what you should be doing now if we have a look now if we do conda on this just to see what packages we've got installed you can see we don't have any packages installed at all so if you were to want to create a project in this particular environment that you've just created here you would need to install the correct packages now as i said that can be all be done in in one command when you set the environment up but there's no need to do that you can then just use condor install and install the packages that you need for this particular environment when you want to exit this environment when you're finished working in it you just type conda deactivate and you're back into your base environment so that's a very brief introduction to using environments in anaconda this is the simplest way of doing it but this at the very least this is what you should be doing for every new project that you do in anaconda create a new environment sometimes if i'm just doing for example data visualization projects or i'm doing a lot of little projects that all have the same packages requirements in terms of packages and the same dependencies i might have an environment that i create for small projects like that and then i can use more that i can use that environment for more than one project but if you're doing bigger projects then it's really important to make sure that you have an environment for each of them
Info
Channel: Python Programmer
Views: 18,839
Rating: undefined out of 5
Keywords: python, learn python, anaconda, how to set up anaconda environments, environments in anaconda, learn to code, data analysis, data science
Id: nZcE3ZMDYHE
Channel Id: undefined
Length: 6min 43sec (403 seconds)
Published: Mon Dec 21 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.