How to Install DuckDB on Ubuntu 24.04 LTS (Step-by-Step Guide)

DuckDB is an open-source analytical database built for Online Analytical Processing (OLAP)

Table of Contents

  1. Introduction to DuckDB
  2. Why Use DuckDB on Ubuntu 24.04
  3. Prerequisites
  4. Method 1: Install DuckDB via Precompiled Binary
  5. Method 2: Install DuckDB Using Python (pip)
  6. Method 3: Build DuckDB from Source
  7. How to Verify Installation
  8. Basic DuckDB Usage Example
  9. Tips and Best Practices
  10. Conclusion

1. Introduction to DuckDB

DuckDB is a lightweight, high-performance analytical database system designed for OLAP (Online Analytical Processing). It is often referred to as the β€œSQLite for analytics” because it runs in-process and does not require a separate server.

DuckDB is widely used for:

  • Data analysis
  • Data science workflows
  • Running SQL queries on large datasets
  • Integration with Python, Pandas, and Parquet files

2. Why Use DuckDB on Ubuntu 24.04

Ubuntu 24.04 LTS (Noble Numbat) is a stable and widely adopted Linux distribution, making it an excellent environment for data processing tools like DuckDB.

Key Benefits:

  • Fast analytical queries
  • No server setup required
  • Works seamlessly with Python and Pandas
  • Supports Parquet, CSV, and JSON formats
  • Ideal for local analytics workloads

3. Prerequisites

Before installing DuckDB, ensure your system is up to date.

sudo apt update && sudo apt upgrade -y

You may also need:

  • curl or wget
  • Python 3 (optional, for Python integration)
  • build-essential (for source installation)

Install required packages:

sudo apt install -y curl wget python3 python3-pip build-essential

4. Method 1: Install DuckDB via Precompiled Binary (Recommended)

This is the fastest and easiest way to install DuckDB.

Step 1: Download DuckDB CLI

wget https://github.com/duckdb/duckdb/releases/latest/download/duckdb_cli-linux-amd64.zip

Step 2: Extract the File

unzip duckdb_cli-linux-amd64.zip

Step 3: Move Binary to System Path

sudo mv duckdb /usr/local/bin/
sudo chmod +x /usr/local/bin/duckdb

Step 4: Run DuckDB

duckdb

If successful, you will see the DuckDB interactive shell.

5. Method 2: Install DuckDB Using Python (pip)

If you are working with Python, installing DuckDB via pip is highly recommended.

Step 1: Install DuckDB

pip3 install duckdb

Step 2: Verify Installation

python3 -c "import duckdb; print(duckdb.__version__)"

6. Method 3: Build DuckDB from Source

For advanced users who need the latest features or customization.

Step 1: Clone Repository

git clone https://github.com/duckdb/duckdb.git
cd duckdb

Step 2: Build DuckDB

make

Step 3: Run DuckDB

./build/release/duckdb

7. How to Verify Installation

To confirm DuckDB is installed correctly:

duckdb --version

Or launch the CLI:

duckdb

You should see:

vX.X.X DuckDB
Enter ".help" for usage hints.

8. Basic DuckDB Usage Example

Once inside DuckDB CLI, try a simple query:

SELECT 'Hello, DuckDB on Ubuntu 24.04!' AS message;

Working with CSV File

SELECT * FROM read_csv_auto('data.csv') LIMIT 10;

Query Parquet File

SELECT * FROM 'data.parquet' LIMIT 10;

9. Tips and Best Practices

1. Use DuckDB for Analytics Only

DuckDB is optimized for analytical workloads, not transactional systems.

2. Integrate with Python

Use DuckDB with Pandas for powerful data analysis:

import duckdb
import pandas as pd

df = pd.read_csv("data.csv")
result = duckdb.query("SELECT COUNT(*) FROM df").fetchall()
print(result)

3. Store Data in Columnar Formats

Use Parquet files for best performance.

4. Keep DuckDB Updated

Regularly update DuckDB to get performance improvements and new features.

10. Conclusion

Installing DuckDB on Ubuntu 24.04 LTS is straightforward and flexible. Whether you choose the CLI binary, Python package, or build from source, DuckDB provides a powerful and efficient way to perform analytical queries without the need for a complex database server.

It is an excellent choice for developers, data analysts, and engineers who want a fast, embedded database solution for modern data workflows.

FAQ

Q1: Is DuckDB free to use?
Yes, DuckDB is open-source and completely free.

Q2: Can DuckDB replace PostgreSQL?
No, DuckDB is designed for analytics (OLAP), while PostgreSQL is better for transactional workloads (OLTP).

Q3: Does DuckDB require a server?
No, DuckDB runs in-process and does not require a separate server.

Q4: Can I use DuckDB with Python?
Yes, DuckDB integrates seamlessly with Python and Pandas.

(Visited 3 times, 2 visits today)

You may also like