The Complete Python Library Guide

This article is about a topic that is far more important and even more fundamental than any specific Python tutorial: Libraries.

What Are the Top 10 Python Libraries?

The following list reflects the most important Python libraries based on my experience:

  1. Pandas. “Excel for coders”.
  2. NumPy. Fundamental to many libraries in the data science and machine learning space.
  3. Matplotlib. Plotting and graph visualization.
  4. Scikit-learn. Single-processor machine learning algorithms in Python.
  5. TensorFlow. Google’s machine learning library.
  6. PyTorch. Another machine learning library for production.
  7. OpenCV. High-performance practical AI library for image recognition and other AI-related tasks.
  8. Requests. HTTP for Humans
  9. Selenium. Automation for browsers, i.e., testing.
  10. NetworkX. Graph and network analysis, algorithms, modeling, and visualization.

I would say NumPy is probably the most important of those 10 libraries because it’s fundamental to Pandas, Matplotlib, Scikit-learn, TensorFlow, PyTorch, and even NetworkX.

*** Feel free to start learning NumPy in our in-depth blog article here. ***

Why Using Python Libraries?

Get your hot, freshly-brewed coffee, and let me show you what holds you back more than anything else in your coding productivity.

Imagine you’re starting your own Uber business. You need to get access to a car or you cannot even start to sell your services. For sure, you don’t build the car yourself, do you? Why should you reinvent the wheel – literally?

Yet, when it comes to coding many developers DO reinvent the wheel on a daily basis. They implement basic algorithms on their own again and again. What a waste of resources!

In the physical world, if you don’t know how to build a business, you can go to the local library and look it up. Similarly, in the digital world, if you don’t want to invest hours implementing a web crawler, you simply import a library for web crawlers.

Everything is a library in coding – even the programming language itself. The simple statement x = 3 + 2 is only a high-level representation of low-level functionality. In this case, addition is really only a shortcut for multiple machine code instructions.

Coding is nothing but creating high-level functionality out of low-level functions.

What Exactly is a Python Library?

A Python library is a collection of modules. Many libraries consist of dozens of modules. Some libraries consist of only a single module. A module is a single file such as '' that contains Python code, i.e., functionality to be reused by other coders.

This brings us to the next question.

What Exactly is a Python Module?

Have you ever put code into a file '' and executed this code via 'python'? Congrats, you have already created and executed your own module! In other words, a module is a Python file ending in the suffix .py.

Let’s make the concept of modules 100% clear. Say, you want to implement your own module. How do you do this? Simply create two files (just in your head): '' which contains your main program and '' which contains your minimal module.

Puzzle 1: What is the result of executing 'python' in your shell? (Find the solution at the end of this article.)

# file

# file
import module

(Spoiler alert: solve the puzzle first before continue reading.)

The import statement in Python is simply a convenient way to “copy and paste” the content of the module into your file (without ACTUALLY doing this). Note that you must skip the suffix ".py" when importing a module. (Don’t ask me why.)

Puzzle 2: What is the result of executing ''?

# file
def hi():
    print("Ciao bella!")

def bye():
    print("Ciao bella!!")
# file
import italian_greetings

Clearly, we are not seeing the result of function bye(). The reason is that we have only defined but not yet executed bye().

Great, now you can import modules from a library (=collection of modules) and you can even create your own modules and libraries! Not too shabby.

However, you will quickly become annoyed by always writing the module name like in italian_greetings.hi().

That’s where a new command comes into play: import x as y. Replace the placeholder x with your (shorter) module name y.

Puzzle 3: What is the result of executing ''?

# file
def hi():
    print("Ciao bella!")

# file
def hi():
    print("Guten Tag!")
# file
import german_greetings as de
import italian_greetings as it


But how do we get rid of these prefixes completely?

It’s time to introduce a third command (after import x, and import x as y): from x import z.

The placeholder x is still a module but z is a specific function in this module. This allows us to do fine-grained imports of just the functions we need. This is useful if we have huge modules with hundreds of functions or if we want to laser-focus our imports.

Puzzle 4: What is the result of executing

# file
from german_greetings import hi
from italian_greetings import bye

Next, you’ll learn about a very important topic in Python: pip.

When you install Python, the most useful packages are already pre-installed. These packages form the “Python standard library”.

Although the standard library is huge, it contains only a fraction of all Python packages. If you create your own Python package, it is not included in the standard library by default. So how can other people benefit from your hard work creating your own Python package? And, more importantly, how can you leverage other people’s work? The answer is PyPI.

What is PyPI?

PyPI is an acronym for “Python Package Index”. It’s a HUGE collection of Python packages. PyPI gives you access to over 113,000 Python packages. It’s a powerful source of knowledge!

Each Python package contains many function definitions. Thus, millions of functions are waiting to be leveraged by you! If you have any problem, it is likely that a similar problem is already solved by a much better developer who invested days, if not weeks, into developing an efficient solution.

So how can you access this big honeypot? The answer comes with yet another acronym: pip.

What is Pip and How to Use It?

Pip is an acronym for the phrase “Pip installs packages” (yes, it’s recursive). And this is exactly what pip does — it installs packages for you. Without pip it’s a pain to install packages: you would have to manually download, decompress, and install the package via "python".

With pip, however, installing new packages is as easy as running "pip install xyz" in your command line. And pip is already installed with most modern Python distributions. It’s already at your fingertips.

So before spending hours creating Python code to solve a problem, search PyPI for relevant Python packages first. If you do not find a package, search even harder. Only if you still do not find a package, consider giving back to the awesome Python community by submitting your own package to the PyPI repository – it’s a simple git request (see the Git cheat sheet).

Puzzle Solutions

Here are the solutions to the puzzles in this article.

Puzzle 1:

Puzzle 2:
Ciao bella!

Puzzle 3:
Guten Tag!
Ciao bella!

Puzzle 4:
Guten Tag!
Ciao bella!!