Last Updated:

12 libraries for python developers

libraries for python

Web applications, web page scanning, database access, GUI creation, parsing, image processing, and more are just a few of what you can do with the Python programming language.

There is a massive collection of libraries in Python. Given this, many of them are not getting the attention they deserve. In addition, programmers working exclusively in one domain are not always aware of the benefits available to them for other types of work.

Here are 12 Python libraries that you may have overlooked, but they definitely deserve your attention. These libraries have a wide range of usefulness, simplifying everything from accessing the file system, programming databases and working with cloud services to creating lightweight web applications, creating graphical interfaces, working with images, e-books and Word files - and much more.

Some are well known, others less well known, but all of these Python libraries deserve a place in your toolbox.

Purpose of Libcloud: Access to multiple cloud providers through a single, consistent, unified API.

Why use Libcloud: Cloud providers all like to do things their own way, which makes a single mechanism for working with dozens of providers a huge time saver and a consolation from headaches. APIs available for compute, data storage, load balancing, and DNS, with support for Python 2.x and Python 3.x, as well as PyPy, a just-in-time (JIT) compiler to improve Python performance.

Arrow

Purpose of Arrow: Cleaner processing of dates and times in Python.

Why You're usingArrow: Working with time zones, date conversions, date formats, and everything else is a headache. Add a standard Python library for working with date and time, and you'll make life even harder.

Arrow has four main advantages. First, this library is a replacement for the Python datetime module. This means that normal function calls, such as .now() and .utcnow(), work as expected. Second, Arrow provides methods for common needs, such as shifting and converting time zones. Third, Arrow provides "humanized" date/time information – for example, the ability to say that something happened "an hour ago" or will happen "in two hours" without much effort. Fourth, this library can localize date/time information.

Behold

Behold is responsible for reliably supporting print-style debugging in Python.

There's one easy way to debug in Python or almost any programming language, for that matter: insert built-in print statements. But while print debugging isn't a problem in small programs, it's not easy to get useful results in large, stretched, multi-module projects.

Behold allows you to overlay a single look and feel on the output, mark the results so that they can be sorted using search or filters, and provide contexts between modules so that functions that originate from one module can be properly debugged in another.

Handles many common Python-specific scenarios, such as printing an internal object dictionary, exposing nested attributes, and storing and reusing the results for comparison at other points in the debugging process.

Black

The purpose of Black: Format Python code according to a strict and almost completely unchanged set of rules.

Why use Black: Python for formatting code, like YAPF, usually has many configurable parameters – line length, line separation variants, processing finite commas, and so on. The Black library applies a sequential set of default values for rules that cannot be changed. The resulting formatted code is as consistent as possible between the code bases and between users, with the smallest possible difference between the edited files.

This library takes some getting used to, especially if you're picky about vertical spaces, deep-nested statements (such as lists within lists), and other formatting options. But ultimately, it frees you from having to think about formatting, allowing you to focus on your code.

Bottle

Purpose of Bottle: Easy and fast web applications.

Why use Bottle: Bottle when creating web applications will give you no more than you need.

Routing, templates, access to request and response data, support for multiple types of servers from simple old CGI and above, and support for more advanced features like WebSockets are all here. The amount of work required to get started is also minimal, and the library's design elegantly expands when more advanced features are required.

Click

Purpose of Click: Allows you to quickly create command-line interfaces for Python applications.

Why use Click: The GUI is convenient, but the CLI is where the real power lies. However, creating a robust CLI is hardly easy, and the default set of tools for collecting and using command-line parameters in Python is primitive.

If you just want to create a few basic commands, you can do so with a few lines of code. If you want to get more advanced behavior, such as requesting additional information about a parameter separately or retrieving values from environment variables, click the covered button. Click also supports terminal colors through the colorama library and can be extended with third-party plugins.

EbookLib

Purpose of EbookLib: Read and write .epub files.

Why use EbookLib: Creating eBooks usually requires the use of a command-line tool. EbookLib provides management tools and APIs that simplify this process. It works with EPUB 2 and EPUB 3 files, and Kindle support is under development.

Provide images and text (the latter in HTML format), and EbookLib can assemble these snippets into an eBook with chapters attached to the table of contents, images, HTML markup, etc. Cover data, spine, and style sheets are also supported. The pluggable system allows third parties to extend the library's behavior.

If you don't need everything that EbookLib has to offer, try Mkepub. Mkepub packs the basic functions of assembling e-books into a library of only a few kilobytes in size. One of the minor drawbacks of Mkepub is that it requires Jinja2, which in turn requires the corresponding MarkupSafe library.

Gooey

The purpose of Gooey is to give Python console programs to the native GUI platform.

Why you use Gooey: Presenting a command-line interface to users, especially casual users, is one of the best ways to discourage users from using your app. Few people, other than a hardcore geek, like to figure out which options to pass on and in what order. Gooey takes the arguments expected by the argparse library and presents them to users as a graphical interface through the wxPython library.

All options are marked and displayed with the appropriate controls (for example, a drop-down list for a multiple-choice argument). Very little additional coding — one include and one decorator — is required to make it work, assuming you're already using argparse.

Invoke

The purpose of Invoke is: Python icremote execution— that is, performing administrator tasks using a Python library.

Why use Invoke: Use Python as a replacement for common shell script tasks. Invoke provides a high-level API for executing shell commands and managing command-line tasks.Be careful not to allow unreliable input to be passed.

Nuitka

Purpose of Nuitka: Compiling Python into standalone C executables.

Why use Nuitka: Like Cython, Nuitka compiles Python into C. However, while Cython requires its own custom syntax for best results and focuses primarily on mathematical and statistical applications, Nuitka works with any Python program as is, compiles it into C, and creates a single-file executable file, applying optimization where possible.

Nuitka is still in its early stages, and many of the planned optimizations are yet to come. However, it's a convenient way to turn a Python script into a quick command-line application.

Numba

Purpose of Numba: selective acceleration of mathematical functions.

Why use Numba: The world of Python includes a whole subculture of packages to speed up mathematical operations. For example, NumPy works by wrapping high-speed C libraries into a Python interface, and Cython compiles Python into C with additional typing to speed up performance.

Numba, in turn, is the most convenient, as it allows you to selectively speed up Python functions with just a decorator. To further improve speed, you can use common Python idioms to parallelize workloads or use SIMD or GPU instructions.

Note that you can use NumPy with Numba. After all, NumPy has many ready-made algorithms that don't need to be implemented from scratch. But for small algorithms, the "core" of Numba is in many cases many times superior to NumPy.

Openpyxl

The purpose of Openpyxl: Read, write, and manipulate Excel files.

Why use OpenPyxl: Ask someone to name three tools that use numbercrunchers in their work, most likely you will get Python, R and Excel. Excel (yet) does not have its own connection to Python, but third-party packages have bridged this gap in various ways.
Openpyxl works by modifying Excel files, not by direct manipulation.

With Openpyxl, you can automate the creation of spreadsheets and books, generate formulas, populate cells with these formulas, and perform many other operations. You can also change the properties of Excel objects, such as cell styles and conditional formatting. Anyone who spends considerable time looking at spreadsheets will find something useful here.