How To Install Python Packages In Virtual Environments

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what is up everybody welcome back to case digital in today's video I wanted to answer the question of how do you install a python package into a virtual environment in Python um and this is probably gonna be pretty quick but I just like this is a common question I think comes up because sometimes you are doing pip install and it's just not going to where you wanted to the key thing to installing a package in Python into your virtual environment is making sure one you have your virtual environment and then it's activated right so if I look at my terminal right here a lot of times in the terminal it'll tell you whether or not your your virtual environment is activated now um on Windows when I do programming on Windows I usually use the windows environment like um the get bash show which allows it kind of acts like more of a Linux environment rather than by Powershell or just the command the the command prompt in Windows um because I like the when the Linux terminals or those type of terminals because they show you when they're active like if I look at this this right over here you can see that it just is showing you like there's nothing extra there's nothing new there's it's just kind of the same old just terminal thing of like the user the name of the the computer and where you are at like what folder you're in on that computer right or the the very base folder that you're in now to install that version so what we need to do is we need to activate our virtual environment to install a package into it right so um when I say so if I LS this folder you'll see like this is the YouTube tutorials video that I do a lot of these YouTube tutorials um you can see that I have two environments in here and that's this one EnV and the Z EnV now this is one I've been testing with some lately um this is the one that I've been doing most of our other stuff in I'm going to activate this one and I'll show you what activating room looks like so you can see the difference but if I say Source um Z EnV bin now if you're on Windows for some reason they made it say it's the name of the thing slash scripts slash activate rather than bin but on Linux and Mac it's slash bin slash activate now if I do this now look here is the original terminal or The Terminal prompt now look what there is there is this little like parenthesis Mark there saying hey your activate or you're working inside side of this virtual environment this python virtual environment now if I deactivate it or turn it off and I say Source EnV slash bin slash activate you'll see that hey look now I'm in the the other virtual environment right so if I want to say so this virtual environment I know um has matplotlib installed um just a graphing tool it helps you do create graphs or whatnot in Python let's add that to this EnV so like let's go install it so now what I need to do is I need to make sure to add it to the Z EnV rather than just EnV environment I need to activate this one again now to do that we'll deactivate our current session with our other virtual environment now I will activate um the Z EnV python environment connectivate and then right here I can say pip list like you've probably seen in some other videos is this tells me everything I have installed now if I want to install a virtual or a python package into this we just now since this is activated right and this this right here is telling you that it's activated I can just do the normal hit install um Matt plot lib right if you want you could also do python Dash m means using this module just hit install but you could also do it this way so now if I go ahead and install it this will go and that's everything that needs to download grab all the extra dependencies that is that matplotlib is needing um and now once this is finished installing all I should need to do is essentially do pip list or pip freeze and show you all the packages so look they're just finished and now I can just say pip list and now you see all of the packages that got installed with that and so there you have it in that virtual environment I installed all these different packages now if I did um deactivate that'll just take us out of that environment again and if I want to go back in again remembering that I need to Source the environment until I can just do that hit list and they'll all still be in there and then there you go you can take this virtual environment and continue your programming and whatever you need it for for your current program but that is essentially how you install a python package into a virtual environment if you have any questions about this or you're having trouble or seeing something or seeing it's you're forever reason your python package is not there um leave a leave a comment down in the comments below and I'll do my best to answer them and until next time keep on programming
Info
Channel: Case Digital
Views: 5,377
Rating: undefined out of 5
Keywords: Software, software developer, developer, python, python tutorial, programming, programmer, python programming, how to install python packages in virtual environments, how to add a python package to a virtual environment, python virtual environment, python virtual environment explained, how to activate a python virtual environment, how to deactivate a python virtual environment, how to install a package into a python virtual environment
Id: kFUHB_8JJEw
Channel Id: undefined
Length: 4min 22sec (262 seconds)
Published: Thu Jan 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.