Python Tutorial: pip - An in-depth look at the package management system
Skills:
AI Productivity Tools80%
Key Takeaways
Installs, uninstalls, lists, and upgrades packages using pip, Python's package management system
Full Transcript
hey what's going on everybody uh today I wanted to take a look at the python package manager pip and also go over some of the most frequent commands that you're going to use uh whenever uh you start the use pip um so with that let's uh go ahead and get started so first things first one of the best resources is if you just type in PIP help then it will bring up all the commands and options that you can use uh so you can see here there's not a whole lot but um it shows you um install uninstall freeze and also uh some of the options that you can use um also uh with that we can also do a pip help and then we can type in a specific command so if I type in PIP help install now it's going to bring up the options for install so you can see here um that we have a Tac R for a requirements file um you can do an upgrade and also install things uh per us user basis and things like that so with the help files out of the way uh let's go ahead and take a look at how we'll actually use this um so say you want to find a package um if you're looking for a package and you don't know exactly what it's called you can just do a pip search um so let's say I do a pip search on this package and it is going to return to me the package name and also a description of the package here um so once you find the package name name then you can go ahead and install it so I'll do a pip install and choose the package that we searched for and now you can say see that it says that this was successfully installed um so if we want to take a look at our installed packages we can do a pip list and it will show us all the packages that we currently have installed so you can see here this is the package that we just installed um if we don't want that package we can do a pip uninstall and choose that package and then it's going to ask us if we want to continue hit yes now you can see that it's successfully uninstalled and now let's do another pip list and you can see that that package that we just uninstalled is no longer listed another thing you'll notice whenever it lists packages it lists the package and it lists the version number uh so how do you know if this version is the latest version of this package um well with Pip list we can do a TCT Tac outdated or we can just do a single Dash with an O hit enter and now you can see one of our packages uh isn't running the latest version of the package uh the setup tools uh the current version that we have installed is uh 12 and the latest is 15 um so to update this package what we'll do is a pip install and then an uppercase U for upgrade and then we can type in the package now you can see that was successfully installed if I do a pip list of the packages now you can see that our setup tools is at the latest version now for demonstration purposes uh let me go ahead and reinstall the package that we uninstalled a little bit ago and now if I do a pip list now let's say that you're working on a project and you want to uh provide maybe somebody else who wants to work on the project you want to provide them with a list of all the packages that they need for that project um now one thing you could do is just type out pip list and then they could manually copy down all of those packages and version numbers and install them that way but if you have a really long list of packages then this definitely isn't the best way to do it for this we're going to use something called uh freeze command if we type in PIP freeze and what this does is it outputs all of our packages and version numbers in a requirements format um so if we wanted to uh send this to somebody then what we could do is pipe this or actually output this uh to a requirements file so I can type in requirements.txt and and hit enter now if I do cat requirements.txt you can see that it lists our package and version number so if you were to send this requirements text file to somebody uh how would they install all those packages using pip um well I have a sample file here that I'm going to use this R test.txt and you can see I have a a few packages listed here so let's say I wanted to install all of these packages now the way you would do this is you would type in PIP install and then attack R and what the r is is it's saying hey we're going to use a requirements file and the name of this file is RoR test.txt hit enter and it's going to go through and it's going to install all those packages and that version of that package now that those are finished installing if I do a pip list then you can see it has installed all those packages at the um exact same version number that was in the requirements file now those simple Basics are pretty much um what you're going to use pip for most of the time um but I do want to show you one last trick here um these packages that I just installed if I do a pip list outdated now you can see I have multiple packages here that are out of date now I could go through and do uh pip currently doesn't have a way to upgrade all packages that need upgraded um you could go through and do each one of these manually uh but if you have a lot of packages then you know that could be a a lot of time to waste um so on stack Overflow uh there uh is an answer here by RBP and he gives this good command here that will go through and do this for you so let me paste this in and walk through exactly what it does okay so first we have Pip freeze which outputs all of the requirements uh for the packages that we currently have uh this TCT Tac local here um if you're in a virtual environment that has access to your Global packages then it'll only print out local packages and then you pipe that output to this grep command here and actually I'm not entirely sure what this grep command does I think he has it uh listed on his answer over here um so this skips - e package definitions um I've never run into that but um maybe it's uh useful for some cases so then after it runs to that GP command then it gets piped in to this uh cut command here and what this cut command does is it sets the delimer to an equal sign and uh then it only returns uh the first uh argument back of that result um so let's see exactly what that would look like here so if I go all the way back here to this GP command and hit enter Then you can see it outputs all of these requirements files with these equals equals and then the version number and whenever you add in that cut command um all it does is it will cut out after or before the uh equal sign there and only return the package name so now we have a list of all of our packages and then lastly the last part of the command um takes this output as arguments one at a time and runs that to the command pip install Tac U which we went over earlier which is upgrade and that will go through and upgrade every one of the packages that uh we had outputed so if I hit enter there now you can see that it's going through each package that needed upgraded and is doing so now after that's finished updating if I do a pip list you can see the list of all our packages and uh version numbers if I do a pip list outdated then we shouldn't have any listed yep and it returned um with no packages that need an upgrade so that about does it I hope that this uh quick overview of pip was useful for you guys um if you do have any questions just feel free to leave those in the comment section below um be sure to subscribe for future tips and tutorials and thank you for watching
Original Description
In this video, we will take an in-depth look at Python's package management system, pip. We'll walk through how to install, uninstall, list, and upgrade packages. We will also dive into how we can output our dependencies and install a list of dependencies.
An in-depth knowledge of pip can be a great addition to your Python tool-belt.
✅ Support My Channel Through Patreon:
https://www.patreon.com/coreyms
✅ Become a Channel Member:
https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join
✅ One-Time Contribution Through PayPal:
https://goo.gl/649HFY
✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey's Public Amazon Wishlist
http://a.co/inIyro1
✅ Equipment I Use and Books I Recommend:
https://www.amazon.com/shop/coreyschafer
▶️ You Can Find Me On:
My Website - http://coreyms.com/
My Second Channel - https://www.youtube.com/c/coreymschafer
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter - https://twitter.com/CoreyMSchafer
Instagram - https://www.instagram.com/coreymschafer/
#Python
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Corey Schafer · Corey Schafer · 29 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
▶
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Web fonts using CSS Font Face
Corey Schafer
Using Font Awesome in Desktop Applications (OS X)
Corey Schafer
Sublime Text 2: Setup, Package Control, and Settings
Corey Schafer
ArcGIS API for JavaScript Part 1: Our First Web Map
Corey Schafer
Mac Tip: Windows' Snapping Feature on Mac with HyperDock
Corey Schafer
Linux/Mac Terminal Tutorial: Creating Aliases for Commands
Corey Schafer
ArcGIS API for JavaScript Part 2: Starting Templates
Corey Schafer
Paver Patio Time Lapse
Corey Schafer
Mac Tip: Ways to perform Screen Capturing and Screenshots
Corey Schafer
WordPress Plugins: Imsanity
Corey Schafer
WordPress Tips: Test your theme with Theme Unit Test and Monster Widget
Corey Schafer
Sublime Text 3: Setup, Package Control, and Settings
Corey Schafer
Understanding Binary, Hexadecimal, Decimal (Base-10), and more
Corey Schafer
Mac Tip: Adding Folder Stacks to the Dock
Corey Schafer
CSS Tips and Tricks: Add External URLs to Print Stylesheets
Corey Schafer
JavaScript Arrays: Properties, Methods, and Manipulation (Part 7 of 7)
Corey Schafer
JavaScript Arrays: Properties, Methods, and Manipulation (Part 1 of 7)
Corey Schafer
JavaScript Arrays: Properties, Methods, and Manipulation (Part 5 of 7)
Corey Schafer
JavaScript Arrays: Properties, Methods, and Manipulation (Part 4 of 7)
Corey Schafer
JavaScript Arrays: Properties, Methods, and Manipulation (Part 3 of 7)
Corey Schafer
JavaScript Arrays: Properties, Methods, and Manipulation (Part 2 of 7)
Corey Schafer
JavaScript Arrays: Properties, Methods, and Manipulation (Part 6 of 7)
Corey Schafer
Python Tutorial: if __name__ == '__main__'
Corey Schafer
Sublime Text Quick Tip: "Go To Definition" Click Shortcut
Corey Schafer
How to quickly create favicons for the desktop, Apple/Android devices, tablets, and more
Corey Schafer
Easily Resize Multiple Images Using Picasa
Corey Schafer
Easily Resize Multiple Images Using the Mac Terminal
Corey Schafer
Python Tutorial: virtualenv and why you should use virtual environments
Corey Schafer
Python Tutorial: pip - An in-depth look at the package management system
Corey Schafer
Git Tutorial: Using the Stash Command
Corey Schafer
How Software Engineers, Developers, and Designers can volunteer their skills
Corey Schafer
Git Tutorial: Diff and Merge Tools
Corey Schafer
Git Tutorial: Change DiffMerge Font-Size on Mac OSX
Corey Schafer
Sublime Text Quick Tip: Launch Sublime Text from the Terminal
Corey Schafer
Python Tutorial: str() vs repr()
Corey Schafer
Programming Terms: DRY (Don't Repeat Yourself)
Corey Schafer
Programming Terms: String Interpolation
Corey Schafer
Programming Terms: Idempotence
Corey Schafer
Python Tutorial: Namedtuple - When and why should you use namedtuples?
Corey Schafer
Programming Terms: Mutable vs Immutable
Corey Schafer
Python Tutorial: Else Clauses on Loops
Corey Schafer
Overview of Online Learning Resources
Corey Schafer
Mac OS X Terminal Tutorial: Time-Saving Keyboard Shortcuts
Corey Schafer
Git Tutorial for Beginners: Command-Line Fundamentals
Corey Schafer
Quickest and Easiest Way to Run a Local Web-Server
Corey Schafer
Python Tutorial: Generators - How to use them and the benefits you receive
Corey Schafer
Python Tutorial: Comprehensions - How they work and why you should be using them
Corey Schafer
Chrome Quick Tip: Quickly Bookmark Open Tabs for Later Viewing
Corey Schafer
Programming Terms: Combinations and Permutations
Corey Schafer
Git Tutorial: Difference between "add -A", "add -u", "add .", and "add *"
Corey Schafer
Preparing for a Python Interview: 10 Things You Should Know
Corey Schafer
SQL Tutorial for Beginners 1: Installing PostgreSQL and Creating Your First Database
Corey Schafer
SQL Tutorial for Beginners 2: Creating Your First Table
Corey Schafer
SQL Tutorial for Beginners 3: INSERT - Adding Records to Your Database
Corey Schafer
Linux/Mac Terminal Tutorial: Navigating your Filesystem
Corey Schafer
Python: Ex Machina Easter Egg - Hidden Message within the Code
Corey Schafer
Mac Tip: New Split Screen Feature in El Capitan
Corey Schafer
Setting up a Python Development Environment in Eclipse
Corey Schafer
Git Tutorial: Fixing Common Mistakes and Undoing Bad Commits
Corey Schafer
SQL Tutorial for Beginners 4: SELECT - Retrieving Records from Your Database
Corey Schafer
More on: AI Productivity Tools
View skill →Related Reads
📰
📰
📰
📰
AI Server Cooling Evolution: From Air Cooling to System-Level Thermal Engineering
Medium · AI
I Would Not Mind Being Stuck on Opus 4.8 Forever
Medium · AI
How I Built a Free Online Image & PDF Processing Platform with Vue 3 + FastAPI
Dev.to · IAMUU
I Built a Free AI-Powered YouTube SEO Toolkit With Zero Budget. Here’s What Actually Happened.
Medium · Startup
🎓
Tutor Explanation
DeepCamp AI