Top 10 Essential Python Packages Every Developer Should Know
This article introduces the ten most essential and widely used Python packages—such as NumPy, Pendulum, Pillow, MoviePy, requests, Tkinter, PyQt, Pandas, Pywin32, and pytest—providing concise descriptions, practical code examples, and guidance on when and why to use each in general programming projects.
Python's ecosystem hosts over 200,000 packages, but developers often wonder which are most essential for everyday programming.
1. NumPy
NumPy provides powerful n‑dimensional array objects and mathematical functions, making complex numerical computations straightforward and serving as a foundation for libraries like TensorFlow.
<code>import numpy as np
a = np.arange(15).reshape(3, 5)
print(a)
print(a.shape)
print(a.ndim)
print(a.dtype.name)
print(a.itemsize)
print(a.size)
print(type(a))
b = np.array([6, 7, 8])
print(b)
print(type(b))
</code>2. Pendulum
Pendulum is a drop‑in replacement for the built‑in datetime module, offering intuitive timezone handling and richer parsing capabilities.
<code>import pendulum
now = pendulum.now("Europe/Paris")
# Change timezone
now = now.in_timezone("America/Toronto")
# ISO 8601 string
now.to_iso8601_string()
# Shift by two days
now = now.add(days=2)
</code>3. Pillow (PIL)
Pillow enables opening, manipulating, and saving images in many formats, suitable for basic image processing tasks.
<code>from PIL import Image
im = Image.open("images/cuba.jpg")
im.show()
im = im.rotate(45)
im.show()
</code>4. MoviePy
MoviePy simplifies common video editing operations such as clipping, concatenating, and adding effects, and can be combined with OpenCV for advanced tasks.
<code>from skimage.filters import gaussian_filter
from moviepy.editor import VideoFileClip
def blur(image):
"""Returns a blurred (radius=2 pixels) version of the image"""
return gaussian_filter(image.astype(float), sigma=2)
clip = VideoFileClip("my_video.mp4")
clip_blurred = clip.fl_image(blur)
clip_blurred.write_videofile("blurred_video.mp4")
</code>5. requests
The requests library makes HTTP communication human‑friendly, handling query strings, POST data, and connection persistence automatically.
<code>import requests
from requests.exceptions import HTTPError
for url in ['https://api.github.com', 'https://api.github.com/invalid']:
try:
response = requests.get(url)
response.raise_for_status()
except HTTPError as http_err:
print(f'HTTP error occurred: {http_err}')
except Exception as err:
print(f'Other error occurred: {err}')
else:
print('Success!')
</code>6. Tkinter
Tkinter is the standard GUI toolkit bundled with Python, providing a simple way to create cross‑platform graphical interfaces.
<code>from tkinter import *
window = Tk()
window.title("Welcome to LikeGeeks app")
window.mainloop()
</code>7. PyQt
PyQt offers bindings to the Qt framework, suitable for building more complex, feature‑rich desktop applications.
(Image omitted for brevity.)
8. Pandas
Pandas excels at data manipulation and analysis, offering powerful data structures like DataFrames for handling tabular data.
<code>import pandas as pd
import numpy as np
dates = pd.date_range("20130101", periods=6)
df = pd.DataFrame(np.random.randn(6, 4), index=dates, columns=list("ABCD"))
print(df)
</code>9. Pywin32
Pywin32 provides access to many native Windows APIs, enabling tasks such as automating Excel or interacting with the registry.
<code>import win32com.client as win32
excel = win32.gencache.EnsureDispatch('Excel.Application')
excel.Visible = True
input("Press ENTER to quit:")
excel.Application.Quit()
</code>10. pytest
pytest is a flexible testing framework that supports simple unit tests as well as complex functional testing.
<code># test_capitalize.py
import pytest
def test_capital_case():
assert capital_case('semaphore') == 'Semaphore'
def test_raises_exception_on_non_string_arguments():
with pytest.raises(TypeError):
capital_case(9)
</code>These ten packages form a solid foundation for general Python development, covering numerical computing, date handling, image/video processing, HTTP requests, GUI creation, data analysis, Windows automation, and testing.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.