How To Manage Conda Environments

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] what's up everyone welcome back to another Anaconda Essentials tutorial and in this one I'm going to show you how to manage cond environments so let's say you've got Anaconda with python 3.5 installed and you got it set up just the way you like it but you've heard python 3.6 is out and you want to try it well you don't have to delete everything and reinstall and a condo with 36 what you can do instead is create a condo environment and your 3.5 and your new 3.6 well those can coexist without affecting each other you can set up your 3.6 environment however you like install whatever packages you want you can even have multiple versions of python and they can all exist without affecting each other or Messing each other up so if that didn't make sense let me start by showing an example so let's get started so I'm going to jump over to my command window and if I type python you can see I've got Anaconda with python 3.5 installed [Applause] so let me start off by showing you how to create a cond environment so the command for this is cond create D- name and we're going to give a name to our environment I'm going to call it Pi 36 and then we specify the version of python we want so we say python equals 3.6 and then we list all the packages we want and you have to give it at least one so I'm just going to say pip and numpy it's going to ask me if I want to install them I'm going to say yes and we're done so if I want to use this environment well what I have to do is activate it first so I'm just going to type activate and then the name of the environment Pi 36 so you can tell it's activated by the name of the environment shown right here so now when I type python you can see that I've got a python 3.6 open up and I can import num numpy and I don't get an import R but let's say I want to use a map plot lib so when when I import map plot lib you can see I get a module not found error that's because I didn't install it or I didn't specify it when I created the environment so if I want to install it I can do it like I would any other package so what I'm going to do here is I'm going to use cond instead of pip and I'll explain why I'm using cond instead of pip later so while my environment is activated I'll just type cond install Matt plot lib I'll say yes to install these so now when I go back into Python and I import Matt plot lib no more module not found eror so the reason why I use cond instead of pip well let me show you so if I were to do cond list D- explicit you can see that it's listing all the packages that I installed so if I were to use pip well I wouldn't get those packages uh I'm not exactly sure why it works like that but when you use the explicit flag you don't get the PIP installed packages and this will come important later on in the video so now if I want to check what environments I have installed the command for that is cond info D- envs so you can see I have the pi 3.6 environment that we just created I've got a tensorflow environment and I have my root install and the asterisk indicates which is the active environment so if I want to deactivate and go back to my root environment I can just use the command deactivate now let's say for example you're working with a group of people on a project and you want to make sure everyone is using the correct version of Python and the correct packages well the easiest way to make sure everyone is on the same page is to have someone create an environment exactly the way you need it to be and then you can create a requirements file which you can then share with your group and then they can use that when they create their environment to get the correct version of Python and the correct packages along with their versions so let me show you how to do that so let's jump back over to the command window and I'm going to create my environment let's do cond create dasn we don't have to do the whole-- name we can just use dashn and we'll call it pro project one and let's use Python 2.7 and then let's use um pip numpy and flask so I'm GNA say yes to install this package or this setup and then let's [Applause] activate project one now that the projects activated let's say oops I forgot to install a package so let's do cond install um let's do PI [Applause] installer oh looks like that's not there let's try again let's do cond install map plot lib and again the reason why I'm using cond is so I can use that explicit flag when I do cond list so I'm going to say yes so now when I type cond list D- explicit you can see we've got everything that we specified uh a bunch of the flask stuff pip numpy is in there somewhere right there and the map plot lib stuff so now in order to create the requirements file I'm going to use the same command and one note we have to do this when the environment is active so we'll use the cond list-- explicit then we use the arrow and we give it a file name so what we'll do is we'll call it uh project one rex. txt so now that that's created let's go in and check out what's in that file so project one txt so basically it's all the stuff that we had listed when we use that command cond list explicit so now you can even see at the top of the file it says this file may be used to create an environment using cond Create Dame whatever your name is-- file so let's try doing that so let's first let's deactivate and now that we're in the same directory where the files at you can do cond create dasn let's call it project 1 B just so we give it a different name from the one that I've already created and then we feed it the file so we do D- file and we call it project one Rex and we're done so now if I were to activate my project 1B and do cond list-- explicit you'll see that my new environment is an exact copy of the previous one so that's how you export a requirements file and install an environment based on a requirements file so lastly I want to show you how to remove an environment first let's deactivate go back into our rout and then the command for removing an environment is cond remove dasn and first let's get rid of project project 1B D- all so it's going to ask me if I want to remove all this stuff I'm going to say yes now when I do cond info D- envs you'll see that project 1B is gone and finally let's get rid of project one so we'll do k-n project one oops cond remove dashn project one-- all I'll say yes cool so now if I do cond info both project project one and project 1B are done so lastly if you ever need help with some of these cond install or cond list commands what you can do is just use the help flag so for example if I do k-h you can see it gives me all the options I have to use with cond so there's cond list cond create cond install update Etc and then if I need information on say cond create well I can just do cond create DH and then I can get more information on what to use with cond create so if you don't like going to the command line for help you can always come to the website so they have a a website with all the information that basically all the stuff I went through in this video on this website so here you can see managing environments creating listing removing sharing cloning all those sorts of things so that's it for this video If you guys liked it leave it a like if you have any questions or if I missed anything or any commands you'd like to see talked about um leave a comment below I'll try my best to get to it and maybe do a follow-up video so one more thing if you check the the homepage on YouTube You'll see there's a link to a Facebook group so if you go there feel free to comment or contact me directly and I'll try my best to provide a little bit of oneon-one help and get a little bit quicker feedback to help help you guys out so yeah feel free to use that and that's it so if you like the content hit the Subscribe button so you can get more videos on this in the future so that's it see you [Music] guys
Info
Channel: Mark Jay
Views: 27,137
Rating: undefined out of 5
Keywords: anaconda, conda, conda environments, python, conda env, virtual environment, pip, requirements, install, miniconda, numpy, how to, tutorial, conda docs, matplotlib, python3.6, python2.7, python3
Id: 9Sfs7Fbvtdk
Channel Id: undefined
Length: 10min 48sec (648 seconds)
Published: Fri Jun 02 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.