Python Package Repositories
Note: The version of PyPI you see in this video has been superseded by the “Warehouse” version of pypi.org that I’ll introduce in the next lesson. If you already know the basics of how the PyPI package repository works, feel free to skip ahead to the next lesson to see the new layout and website design for PyPI.
00:00 An important part of dependency management is of course the ability to store packages somewhere so that you or other people can install them. Now, let’s talk about Python package repositories.
00:14 Python packages are collected in so called software repositories. The biggest, or official software repository in Python is called PyPI. It’s also sometimes called The Cheese Shop, because Python developers just love their Monty Python references.
00:32 Developers can register for a free PyPI account and then submit new packages to the repository. And once a package appears in PyPI, everyone else can install it through pip, so this is a really popular method to distribute open source Python packages, and there are literally tens of thousands of packages available for free, that you could just install through pip.
00:55 And by the way, there is no review or QA process for packages submitted to PyPI. So whenever you install a package from PyPI, it makes sense to invest some time into due diligence work and reviewing what’s available, so that you get a quality piece of software.
01:10 Let’s search for some packages on PyPI. We’re going to take a look at the PyPI website now, and you can find it at pypi.python.org. Lets fire up a browser and then take a look at the PyPI website.
01:26 Alright, this is PyPI, you can see some stats here so right now, they are close to a 100 thousand packages available here, on PyPI, and when you scroll down, you can see sort of a update log of recently updated packages as people pushed them to the package repository you can see here what was updated.
01:47 And of course, one of the most important parts of the site here is the search box. So into the search box, you can enter keywords and basically do a full tech search on the descriptions and the metadata for the packages available on PyPI, so you’ve probably heard of the really popular Requests package, which is a HTTP download library, so I am going to go ahead and search for Requests here.
02:12 Okay, so these are the search results for Requests, and what is interesting here is that the actual Requests library that I was looking for, is not the number one search result, right, because this is just doing a search across all of the descriptions and the metadata in all of the available packages.
02:28 So I get some very exhaustive results here, and you can see here as I scroll down this is a really long list, because, obviously the keyword Requests seems to be quite popular.
02:38 Alright, so I am going to go ahead and click on the Requests library here, because, every package in PyPI actually has its own landing page, so it has its own page on PyPI where the developers can host the README and give some links to the documentation or release history, and stuff like that.
03:00 So what you can see here is that right now I am looking at the specific version of Requests, and you can also see that reflected here in the URL, so this will be at PyPI (slash) name of the library (slash) the version.
03:13 So this is handy if you ever want to link to a specific library or a specific version of library, because you can just use that link. This is the README file or the description that the creators of the Requests library have put together.
03:27 So the contents of this description here largely depend on the information that the library creators put in. Sometimes the formatting as it’s displayed on the PyPI website isn’t perfect, so you are going to get these super blown up images here, just ignore that for now.
03:43 Actually, what I wanted to show you is when you scroll all the way down here, there will always be the summary with metadata about the package that you are looking at, and this is often very useful if you want to find the homepage for a specific project or if you want to identify its author or if you are interested in the license that the code is under.
04:10 Then, also, you can see the categories the code is filed under, or the library it was filed under, and then also what other dependencies or secondary dependencies that library requires.
04:21 To me, the most useful information is usually these top three items here, I want to know about the library author, I usually take a look at the library home page and then I also want to know what license the software is under.
04:34
And of course, you could also click through these categories here and maybe find some interesting packages that way. Okay, that’s it for PyPI. You can also search for packages from the command line, using the pip search
command.
04:49 Usually I would recommend that you stick with the PyPI website though. The pip command doesn’t really give you very much information about those search results so it’s just the package name and then a very brief description, which can be useful but as you’ve seen in the PyPI demo, oftentimes, a single keyword can lead to many search results so it’s a little bit hard to untangle that from the command line if you only have limited information available.
05:15 Nevertheless, that feature exists and it can be useful in a pinch.
aravind on Sept. 16, 2019
Hi - in what way is this part outdated? I am following it right now and need to know. Will we receive course refund if this is no longer the correct process to package python libraries? Thanks.
Dan Bader RP Team on Sept. 16, 2019
Thanks for the comments. The version of PyPI you see in this video has been superseded by the “Warehouse” version of pypi.org that I’ll introduce in the next lesson right after this one :)
If you already know the basics of how the PyPI package repository works, feel free to skip ahead to the next lesson where I go over the new layout and website design for PyPI. Functionality-wise they’re both very similar, but the new version is prettier and easier to use.
Happy Pythoning!
Kris Stenglein on July 7, 2021
So in my command line I currently have both a ‘pip’ command and ‘pip3’ command. When I check their version, however, they both seem to point to the exact same spot:
pip 21.1.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
So does it matter which one I use to install packages?
Leodanis Pozo Ramos RP Team on July 7, 2021
Hey Kris! In this case, it looks like you have a single Python installation (3.9) on your system. If that’s the case, then you can use either pip
or pip3
to manage your Python packages.
However, best practices recommend using an explicit command to make sure you’re installing your packages in the right environment or interpreter. For example, if you want to install django
in your Python 3.9 environment, you can do something like this:
$ python3 -m pip install django
If you have more than one Python 3.x installation, then you’d need to be more explicit and do something like this:
$ python3.9 -m pip install django
Happy Pythoning!
Become a Member to join the conversation.
z on Sept. 14, 2019
This part of the course is obviously out of date. Need some update.