How to use Boto3 and AWS Client to determine whether a root bucket exists in S3?

Ashish Anand
Updated on 25-Mar-2026 18:08:44

613 Views

When working with AWS S3 using Python, you often need to verify if a bucket exists before performing operations. The Boto3 library provides the head_bucket() method to check bucket existence and access permissions. Approach The solution involves these key steps: Step 1 − Import boto3 and botocore exceptions to handle errors Step 2 − Create an AWS session using boto3 library Step 3 − Create an AWS client for S3 Step 4 − Use head_bucket() which returns 200 OK if the bucket exists and you have access, or 403/404 for permission/existence issues Step 5 − Handle ... Read More

How to use Boto3 library in Python to get the list of buckets present in AWS S3?

Ashish Anand
Updated on 25-Mar-2026 18:08:27

499 Views

The Boto3 library is the AWS SDK for Python that allows you to interact with AWS services programmatically. You can use Boto3 to retrieve a list of all S3 buckets in your AWS account using either the resource or client interface. Prerequisites Before running the code, ensure you have: Boto3 installed: pip install boto3 AWS credentials configured (via AWS CLI, environment variables, or IAM roles) Appropriate S3 permissions to list buckets Using S3 Resource Interface The resource interface provides a higher-level, object-oriented approach to interact with S3 ? import boto3 from ... Read More

How to connect different AWS services using Boto3 library in Python?

Ashish Anand
Updated on 25-Mar-2026 18:08:07

865 Views

In this article, we will see how to use the Boto3 library in Python to connect with different AWS services. Boto3 is the official AWS SDK for Python that provides both low-level client interfaces and high-level resource interfaces. Understanding Client vs Resource Boto3 offers two main ways to interact with AWS services: Client − Provides low-level service access with all service operations Resource − Provides high-level object-oriented interface (limited services) Step-by-Step Approach Step 1 − Create an AWS session using Boto3 library. Step 2 − Pass the AWS service name to client() ... Read More

How to create an AWS session using Boto3 library in Python?

Ashish Anand
Updated on 25-Mar-2026 18:07:42

5K+ Views

When working with AWS services through Python, you need to establish a session first. An AWS session handles authentication and provides access to AWS services using the Boto3 library. An AWS session can be created with default credentials or customized based on your specific requirements. Prerequisites Before creating an AWS session, set up authentication credentials. You can find these in the IAM console or create a credentials file manually at ~/.aws/credentials ? [default] aws_access_key_id = YOUR_ACCESS_KEY aws_secret_access_key = YOUR_SECRET_ACCESS_KEY aws_session_token = YOUR_SESSION_TOKEN region = REGION_NAME Install Boto3 using the following command ? ... Read More

Applying Gaussian Blur to an image using the Pillow library

Prasad Naik
Updated on 25-Mar-2026 18:07:22

1K+ Views

In this tutorial, we will learn how to apply a Gaussian blur effect to images using Python's Pillow library. The ImageFilter.GaussianBlur() function creates a smooth blur effect by applying a Gaussian filter with a specified radius parameter. What is Gaussian Blur? Gaussian blur is a widely-used image processing technique that reduces image noise and detail by applying a mathematical function called a Gaussian kernel. The radius parameter controls the blur intensity — higher values create more blur. Algorithm Step 1: Import Image and ImageFilter from Pillow Step 2: Open the target image file Step 3: ... Read More

Applying MaxFilter on an image using Pillow library

Prasad Naik
Updated on 25-Mar-2026 18:07:02

594 Views

In this program, we will apply a maximum filter on an image using the Pillow library. In maximum filtering, the value of each pixel in a selected window of the image is replaced by the maximum pixel value of that window. This creates a dilation effect that brightens the image and expands bright regions. What is MaxFilter? The MaxFilter is a morphological operation that replaces each pixel with the maximum value found in its neighborhood window. It's commonly used for noise removal and feature enhancement in image processing. Syntax ImageFilter.MaxFilter(size) Parameters: size ... Read More

Loading and displaying an image using the Pillow library

Prasad Naik
Updated on 25-Mar-2026 18:06:38

294 Views

In this program, we will read or load an image using the Pillow library. The Pillow library provides the Image.open() method that takes the file path or filename as a string parameter. To display the image, we use the show() function which opens the image in the default image viewer. Installing Pillow First, install the Pillow library if you haven't already ? pip install Pillow Basic Image Loading and Display Here's how to load and display an image using Pillow ? from PIL import Image import io import base64 # ... Read More

How to overplot a line on a scatter plot in Python?

Rishikesh Kumar Rishi
Updated on 25-Mar-2026 18:06:20

14K+ Views

Overplotting a line on a scatter plot combines scattered data points with a trend line or reference line. This technique is useful for showing relationships, trends, or theoretical models alongside actual data points. Basic Approach Create the scatter plot first using scatter(), then add the line using plot() on the same axes ? import matplotlib.pyplot as plt import numpy as np # Generate sample data x_data = np.linspace(0, 10, 20) y_data = 2 * x_data + 1 + np.random.normal(0, 2, 20) # Linear with noise # Create scatter plot plt.figure(figsize=(8, 6)) plt.scatter(x_data, y_data, ... Read More

Barchart with vertical labels in Python/Matplotlib

Rishikesh Kumar Rishi
Updated on 25-Mar-2026 18:05:55

10K+ Views

When creating bar charts in Python using Matplotlib, you can rotate axis labels to improve readability, especially when dealing with long label names. The xticks() function with the rotation parameter allows you to set labels vertically or at any angle. Basic Bar Chart with Vertical Labels Here's how to create a bar chart with vertical x-axis labels − from matplotlib import pyplot as plt bars_heights = [14, 8, 10] bars_label = ["A label", "B label", "C label"] plt.bar(range(len(bars_label)), bars_heights) plt.xticks(range(len(bars_label)), bars_label, rotation='vertical') plt.show() Different Rotation Angles You can specify custom angles ... Read More

Downsampling an image using OpenCV

Prasad Naik
Updated on 25-Mar-2026 18:05:34

8K+ Views

In this program, we will down sample an image. Downsampling is decreasing the spatial resolution while keeping the 2D representation of an image. It is typically used for zooming out of an image. We will use the pyrDown() function in the OpenCV library to complete this task. What is Image Downsampling? Image downsampling reduces the number of pixels in an image by decreasing its spatial resolution. OpenCV's pyrDown() function performs Gaussian pyramid downsampling, which smooths the image and reduces its size by half in each dimension. Algorithm Step 1: Read the image using cv2.imread() Step ... Read More

Advertisements