Join Hackr.io to get personalized course recommendations for you.

Top 10 General Python Libraries

Posted in Python
Top 10 General Python Libraries

Python is labeled as a “batteries-included programming language.” This simply means that it comes with a number of prepackaged libraries. Nonetheless, there are a galore of other libraries available for the interpreted, high-level, general-purpose programming language.

Among other factors contributing to the popularity of Python, having a humongous collection of libraries is a significant one. The more libraries and packages a programming language has at its disposal, the more diverse use-cases it can have.

Python Libraries

In this part 2 of the Python libraries article (Read Here First Part), we will cover the top 10 general Python libraries. Remember that this list is backed by the findings of the Python Developers Survey 2018.

Requests

Requests

Primary Intent: Making HTTP requests simpler
Secondary Intent(s): None

One of the most popular general Python libraries is Requests that aims to make HTTP request simpler and more human-friendly. Licensed under the Apache2 license and written in Python, Requests is the de facto standard used by developers for making HTTP requests in Python.

In addition to using the Requests library for sending HTTP requests to a server, it also allows adding form data, content, header, multi-part files, etc. with them. With the library, developers need not to add a query to the URL or form-encode the POST data manually.

The Requests library abstracts the numerous complexities of making HTTP requests in a simple API so that developers can focus more on interacting with services. The library offers official support for Python 2.7, 3.4 and above and works great on PyPy too.

Highlights:

  • Allows multipart file uploads and streaming downloads
  • Automatic content decoding and automatic decompression
  • Browser-style SSL verification
  • Features can be customized and optimized as per requirements
  • Keep-Alive & Connection Pooling
  • Supports international domains and URLs

Pillow

Pillow

Primary Intent: Image manipulation
Secondary Intent(s): Image archival, image display

Python Imaging Library or PIL is a free Python library that adds an image processing ability to the Python interpreter. In simple terms, PIL allows manipulating, opening, and saving various image file formats in Python. Created by Alex Clark and Contributors, Pillow is a fork of the PIL library.

In addition to offering powerful image processing capabilities, Pillow offers an effective internal representation and extensive file format support. The core Python library is designed for offering fast access to data stored in a few basic pixel formats.

Highlights:

  • Effective debugging support using the show() method
  • Ideal for batch processing applications
  • Identifies and reads a vast range of image file formats
  • Offers BitmapImage, PhotoImage, and Window DIB interfaces
  • Supports arbitrary affine transforms, color space conversions, filtering with a set of built-in convolution kernels, image resizing and rotation, and point operations
  • The histogram method allows pulling some statistics out of an image, can be used for automatic contrast enhancement and global statistical analysis

Scrapy

Scrapy

Primary Intent: Web scraping
Secondary Intent(s): Automated testing, data mining, web crawling

Scrapy is a free and open-source Python framework that is widely used for web scraping and a number of other tasks, including automated testing and data mining.

Initially, Scrapy was developed for web scraping but has evolved to fulfill other purposes over its course. The library offers a fast and high-level method for crawling websites and extracting structured data from webpages.

Written in Python, Scrapy is built around spiders that are basically self-contained crawlers, which are provided a set of instructions. Abiding by the DRY principle, Scrapy makes it easier to build and scale full-fledged web crawling projects.

Highlights:

  • Easy to write a spider to crawl a website and extract data
  • Follows the DRY principle
  • Offers a web-crawling shell that allows developers to test a website’s behavior
  • Supports exporting scraped data using the command line

Asyncio

Asyncio

Primary Intent: Working with the asynchronous code
Secondary Intent(s): None

Numerous Python developers around the world make use of the asyncio library for writing concurrent code using the async/await syntax. In most cases, the asyncio library is ideal for IO-bound and high-level structured network code.

asyncio has been used for building various Python asynchronous frameworks that offer database connection libraries, distributed task queues, high-performance network and web servers, and much more. The library comes with a number of high-level and low-level APIs.

Highlights:

  • Allows controlling subprocesses, distribute tasks via queues, perform network IO and IPC, and synchronize concurrent code
  • Bridge callback-based libraries and code with async/await syntax using low-level APIs
  • Comes with a set of high-level APIs for concurrently running Python coroutines and having full control over their execution
  • Eases working with asynchronous code
  • Supports the creation and management of event loops, implementing effective protocols using transports

Tkinter

Tkinter

Primary Intent: GUI development
Secondary Intent(s): None

When used with Tkinter, Python offers an easy and fast way for creating GUI applications. Tkinter is the standard GUI library for the Python programming language. It offers a powerful object-oriented interface for the Tk GUI toolkit.

Creating a GUI application using Tkinter is very easy. All you need to do is to follow these simple steps:

  • Import Tkinter
  • Create the main window for the GUI application under development
  • Add one or more Tkinter Widgets
  • Enter the main event loop for taking action for each user-triggered event

Tkinter offers over 15 types of widgets, including buttons, labels, and text boxes. Each of them has access to some specific geometry management methods that serve the purpose of organizing widgets throughout the parent widget area.

Highlights:

  • Comes with a range of widgets that support geometry management methods
  • Eases developing GUI applications
  • Supports an effective object-oriented interface

Six

Primary Intent: Compatibility library (wrapping over differences between Python 2 and Python 3)

Secondary Intent(s): None

Although simplistic, Six is a powerful Python library that is meant to smooth out the differences between various Python 2 and Python 3 versions. Six is intended for supporting codebases that can operate on both Python 2 and Python 3 without the need of modifications.

The Six libraries is super-easy to use thanks to being offered as a single Python file. Hence, it is ridiculously easy to copy the library into a Python project. The name Six reflects (Python) 2 x (Python) 3.

Highlights:

  • Simple utility functions for making Python code compatible with Python 2 and Python 3
  • Supports every version since Python 2.6
  • Too simple to use as contained in a single Python file

aiohttp

aiohttp

Primary Intent: Serve as an asynchronous HTTP Client/Server
Secondary Intent(s): None

Another simple yet widely used Python library is the aiohttp. It is basically meant to be an asynchronous HTTP client or server in Python. Beyond this and offering out-of-the-box support for Client WebSockets and Server WebSockets, there’s nothing more to this Python library.

Highlights:

  • Offers a web server that has middlewares, pluggable routing, and signals
  • Provides out-of-the-box support for both Client WebSockets and Server WebSockets
  • Supports both Client and HTTP Server

Pygame

Pygame

Primary Intent: 2D game development
Secondary Intent(s): Multimedia app development

Pygame is a free and open-source Python library that is meant for accomplishing multimedia application development in Python, especially two-dimensional gaming projects. Hence, it is widely used by both casual and professional Python game developers.

Under the hood, Pygame makes use of the SDL (Simple DirectMedia Layer) library. Like the SDL library, Pygame library is highly portable and thus provides support for a wide number of platforms and operating systems.

It is possible to port applications developed using Pygame on Android-powered devices, like smartphones and tablets. For the very purpose, pgs4a (Pygame subset for Android) needs to be used.

Highlights:

  • Doesn’t demand OpenGL
  • Makes easy for using multi-core CPUs
  • No GUI required for using all available functions
  • Provides support for a wide range of platforms and operating systems
  • Simple and easy to use
  • Uses Assembly code and optimized C code for implementing core functions

Kivy

Kivy

Primary Intent: Application development (with innovative user interfaces)
Secondary Intent(s): None

For building mobile apps and multi-touch application software with a NUI (Natural User Interface), Python developers rely on the Kivy library. The free and open-source Python library is distributed under the MIT license and runs on Android, iOS, Linux, macOS, and Windows.

In actual, Kivy is the evolution of the PyMT project. It contains all the necessary elements for building an intuitive multi-touch application, namely a graphics library, a wide range of widgets with multi-touch support, an intermediate language (Kv), and extensive input support.

Kv, or the Kivy language, is an intermediate language dedicated to describing user interactions and interface. It makes it very easy to create a complete UI and add interaction(s) to it. Kivy also provides support for the Raspberry Pi.

Highlights:

  • Ability to natively use most devices, inputs, and protocols
  • Cross-platform
  • Offers over 20 highly-extensible widgets
  • Support graphics engine built over the OpenGL ES 2

Bokeh

Bokeh

Primary Intent: Developing visualization-based applications
Secondary Intent(s): Data visualization, data science

An interactive visualization library for the Python programming language, Bokeh allows visualizing data in a beautiful and meaningful way inside contemporary web browsers. The data visualization library eases the creation of dashboards, data applications, and interactive plots.

In addition to offering concise and elegant construction of versatile graphics, the Bokeh library also extends its capability with high-performance interactivity over streaming or very large datasets.

Highlights:

  • Allows building complex statistical plots with simple commands
  • Bokeh visualizations can be easily embedded into two of the most popular Python frameworks, Django and Flask
  • Capable of producing elegant and interactive data visualizations
  • Multiple language bindings (Julia, Lua, Python, and R)
  • Various output formats

That’s All!

So, that was the list of the top 10 general Python libraries. Enhancements and upgrades are regularly made to these libraries for keeping up with the increasing popularity and growth of the Python programming language.

Having a knowledge of these popular general Python libraries will further your Python learning and make you a better Python developer. All the best!

People are also Reading:

Vijay Singh

Vijay Singh

My name is Vijay Singh Khatri, and I enjoy meeting new people and finding ways to help them have an uplifting experience. I have had a variety of customer service opportunities, through which I was able to have fewer returned products and increased repeat customers, when compared with co-workers. Currently working with hackr.io View all posts by the Author

Leave a comment

Your email will not be published
Cancel