Guides 11792 Published by

The guide explains how to get the lightweight SQLite database engine up and running on Ubuntu 22.04 or 20.04 by first updating the package list, then installing the command‑line client with `sudo apt install sqlite3`, and finally adding the development libraries if you plan to compile code that depends on SQLite’s headers. It highlights that missing the `libsqlite3-dev` package will cause “cannot find header file sqlite3.h” errors during C or Python builds, so it must be installed early. For users who need newer features not yet in Ubuntu’s repos, the article walks through downloading, configuring, compiling, and installing SQLite from source, noting that this is only necessary if the packaged version lags behind the latest releases. Finally, it lists common pitfalls such as using an old apt cache or forgetting dev libs, reminds readers to verify installation with `sqlite3 --version`, and concludes that the official packages are usually sufficient unless you need bleeding‑edge functionality.



How to Install SQLite on Ubuntu 22.04 or 20.04

SQLite is the lightweight database engine that powers countless apps from your phone to your laptop. If you’re running Ubuntu 22.04 or 20.04 and need a quick way to get it up and running, read on.

Why You Need the Right SQLite Packages

Installing the default sqlite3 package gives you just the command‑line client. If you’ll be coding in C, Python, or another language that relies on the lib, you also need the development libraries (libsqlite3-dev). Without them you’ll hit “cannot find header file sqlite3.h” and have to do a messy manual build.

Step 1 – Update Your Package List
sudo apt update

A fresh index ensures you pull the latest version of SQLite from Ubuntu’s repositories, avoiding weird compatibility hiccups.

Step 2 – Install the Runtime and CLI
sudo apt install sqlite3

This brings in the shell (sqlite3) that lets you play with databases directly. I’ve seen people try to use Python’s sqlite3 module before installing this, only to get “no such file or directory” errors.

Step 3 – Grab the Development Libraries
sudo apt install libsqlite3-dev

If you’re compiling a C program or building a Python wheel that embeds SQLite, this package supplies sqlite3.h and the static library. Skipping it will force you to fetch source code and compile manually—a pain when you just want to run a script.

Step 4 – Verify the Installation
sqlite3 --version

You should see something like 3.37.2 2021-11-28 14:34:00. If it prints a version, congratulations—you’re good to go.

Optional: Installing SQLite from Source (Why You’d Do It)

If you need the absolute bleeding‑edge build or want to tweak compile flags:

sudo apt install build-essential wget
wget https://www.sqlite.org/2023/sqlite-autoconf-3390200.tar.gz
tar xf sqlite-autoconf-3390200.tar.gz
cd sqlite-autoconf-3390200
./configure --prefix=/usr/local
make -j$(nproc)
sudo make install

Why bother? I’ve seen people on Ubuntu 20.04 try to use a feature that only appears in SQLite 3.38, and the packaged version is still at 3.35. Installing from source lets you run that new syntax without waiting for the distro maintainers.

Common Pitfalls
  • Missing libsqlite3-dev – If you forget this when compiling C code, your build will break with “fatal error: sqlite3.h: No such file or directory.” Install it before you start.
  • Using an old apt cache – Running sudo apt install sqlite3 after a long pause often pulls the stale 3.34 release on Ubuntu 20.04. Always update first.
Wrap‑up

That’s all there is to getting SQLite running on Ubuntu 22.04 or 20.04. Install the runtime, add the dev libs if you’re coding, and test with sqlite3 --version. If you need newer features, pull from source; otherwise the official packages are solid.