Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Finding Third-Party Packages

In this lesson, you’ll learn how to find Python packages on PyPI. Choosing the right package is a big topic, so you might want to consult How to Evaluate the Quality of Python Packages before you use pip install in your own projects.

00:00 Third-party packages are external Python packages that are not part of the Python standard library. In this course so far, we installed requests and rich, with some dependency of both packages, and you may have wondered, where does Python exactly find those packages? So in this lesson, I will show you how to find third-party packages.

00:25 The Python Package Index is the official package repository for Python packages. It’s commonly abbreviated as PyPI. pip uses PyPI as the default source to download packages and their dependencies, and anyone can upload packages to PyPI. That’s a really cool thing.

00:46 However, it also has its caveats. So we will get to this in a moment.

00:52 You can browse the PyPI package catalog on pypi.org. So let’s have a look.

01:01 I’m currently on the pypi.org website, so that’s the website of the Python Package Index. You can either browse projects, or you can search for a particular project if you already know what you’re looking for.

01:15 So since we were working with Requests, let’s look for the Requests package in here.

01:23 Once you hit Enter in the search input field, you’ll see that PyPI lists you a bunch of packages that fits the requests search. So there are over ten thousand projects there.

01:36 So that’s why I meant there is a caveat that anyone can upload a package to PyPI. That makes this catalog quite cluttered. However, there are a few things that you can do to find the package that you’re looking for.

01:50 Usually, PyPI already makes a good estimate what you are looking for. So when you’re looking for the Requests package, the top spot in this list is the Requests package that we were using in this course. So if your packages are ordered by relevance, that’s here in the dropdown on the upper right, the first hits are usually quite good. However, there are some other things that you can do.

02:17 You can use the Filter by classifier interface on the left to filter the list a bit more. So currently, we’re having ten thousand of projects that contain the word requests.

02:29 If we are clicking on Programming Language and scroll down, then you can select the Python version that you’re currently working in. And that’s a good idea if you are not sure what package to use.

02:42 So in my case, I want to select Python 3.10, but if you are developing with, let’s say, Python 3.8, you want to make sure that any package that you want to use supports Python 3.8.

02:55 So in my case, again, it’s 3.10, so I click the checkbox there.

03:01 I close the Programming Language tab, and there you can see it’s only 8,276 packages left. So that’s quite a good filter. Another good filter that you can use is taking the development status into consideration. Again, anybody can upload packages, but not all the packages that are there are really in a production/stable mode.

03:25 So there are some alpha, beta, and even inactive projects. Usually what you’re looking for is production/stable, so if you’re clicking the checkbox for this one, then you can see we filtered it down to three thousand packages, and still our Requests package is on the number-one spot. So yeah, that’s our pick. Let’s have a closer look at this package on PyPI.

03:51 After you click on the package name, you get to the detail page, and that’s the page dedicated to a single package. There you can see on the top the pip install command—that’s the one that we are we’re using in this course as well—with a nifty Copy to clipboard function.

04:10 So if you are finding a package there, you can copy this string right there and paste into your terminal. Well, of course, you could also type out this command just like we did in our lessons, but sometimes there are packages that just have a similar-sounding name.

04:27 So, for example, if you would type pip install request without the s in the end, you might download a package that’s not the one that you wanted to use. So it’s usually a good idea to copy this command right here, especially if the names are a bit more complicated, because that way you make sure that you are not downloading any other packages that you don’t want to use.

04:50 One thing that you were able to see on the list, but that’s here on the detail page as well, is when the last release was. So in this case, it’s January 12, 2023.

05:01 That’s quite recent for the time of this recording, and that’s a good indicator that this package is still alive and kicking. So it’s always a good idea to look at the last release.

05:17 To really find a good Python package, there are even more things to consider. If you want to take a deep dive, then I recommend the article How to Evaluate the Quality of Python Packages that we have as a written tutorial on realpython.com.

05:33 It’s a great resource to learn about all the details that you can take into consideration when you’re choosing external packages that you install with pip.

05:42 That’s just one resource that is very relevant for this lesson. In the next lesson, I will share even more resources with you that are related to this course in general. So, see you in the next and last lesson of this course.

Become a Member to join the conversation.