How to Install SQLite in a Python Virtual Environment (pip install sqlite3 Explained)

pip install sqlite3 fails with No matching distribution found, because sqlite3 isn’t a pip package. It ships inside Python itself, so a virtual environment has it whenever its base Python does. In this article I’ll walk you through checking that it works in your venv, and getting a newer SQLite when you need one.

TLDR

  • Don’t run pip install sqlite3. The sqlite3 module is part of Python’s standard library, so a virtual environment has it whenever its base Python was built with it.
  • Check it with python -c "import sqlite3; print(sqlite3.sqlite_version)" inside the activated venv.
  • The SQLite version comes from the SQLite library the venv’s base Python uses, not from pip.
  • The sqlite3 command-line shell is a separate program. Install it with your system’s package manager if you want it.

What are you installing?

There are two different things called “sqlite3”:

NameWhat it isWhere it comes from
sqlite3 Python moduleThe library your Python code importsPython’s standard library, so it’s in any venv whose base Python includes it
sqlite3 shellA command-line program for running SQL by handYour OS or package manager, not pip

Python’s docs describe the module as an interface that “requires the third-party SQLite library”, and call it “an optional module” that whoever built your Python includes (sqlite3 module docs). Homebrew’s Python 3.14, used for this article, includes it.

Prerequisites

RequirementDetail
PythonAny current Python 3 with the venv module. I used Homebrew’s Python 3.14.6 on macOS.
A terminalTo create and activate the venv
pipNothing to install for SQLite itself
uv (optional)Only if you manage Python versions with uv

How to set up SQLite in a Python virtual environment

To show you the steps, I created a venv in an empty folder and ran each command in it.

Step 1: Create and activate the virtual environment

$ python3.14 -m venv .venv
$ . .venv/bin/activate && python --version && which python
Python 3.14.6
/private/tmp/sqldocs-f4-pyvenv/.venv/bin/python

On Windows, activate it with .venv\Scripts\activate instead (not executed here).

Step 2: Check that sqlite3 imports

$ . .venv/bin/activate && python -c 'import sqlite3; print(sqlite3.sqlite_version)'
3.53.4

That number is the version of the SQLite library inside this Python, not a pip package version. There’s nothing else to install.

Step 3: Use it in a script

Save this as check_sqlite.py. It creates app.db and writes one row, then reads it back:

import sqlite3
import sys

print("Python:", sys.version.split()[0])
print("In a virtual environment:", sys.prefix != sys.base_prefix)
print("SQLite library:", sqlite3.sqlite_version)

con = sqlite3.connect("app.db")
con.execute("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT NOT NULL)")
con.execute("INSERT INTO users (name) VALUES (?)", ("ada",))
con.commit()
print("Rows:", con.execute("SELECT id, name FROM users").fetchall())
con.close()
$ . .venv/bin/activate && python check_sqlite.py
Python: 3.14.6
In a virtual environment: True
SQLite library: 3.53.4
Rows: [(1, 'ada')]

Check that it works

The import check in Step 2 is the whole test. A fresh venv lists no SQLite package, because the module comes from the Python install, not from the venv:

$ . .venv/bin/activate && pip list 2>/dev/null
Package Version
------- -------
pip     26.1.2

You can see where the module really lives. Homebrew’s Python doesn’t bundle SQLite: its _sqlite3 module links to Homebrew’s own sqlite package, 3.53.4 here:

$ . .venv/bin/activate && python -c 'import sqlite3, _sqlite3; print(sqlite3.__file__); print(_sqlite3.__file__)'
/opt/homebrew/Cellar/python@3.14/3.14.6/Frameworks/Python.framework/Versions/3.14/lib/python3.14/sqlite3/__init__.py
/opt/homebrew/Cellar/python@3.14/3.14.6/Frameworks/Python.framework/Versions/3.14/lib/python3.14/lib-dynload/_sqlite3.cpython-314-darwin.so
$ . .venv/bin/activate && otool -L $(python -c 'import _sqlite3; print(_sqlite3.__file__)') | grep libsqlite3
	/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 9.6.0)
$ brew list --versions sqlite
sqlite 3.53.4

If the import fails with ModuleNotFoundError: No module named '_sqlite3', your Python was built without SQLite support. Python’s docs say to look for documentation from whoever provided your Python (sqlite3 module docs). Install a Python build that includes the module, such as Homebrew’s python used here.

Why pip install sqlite3 fails

There’s no package called sqlite3 on PyPI, so pip can’t find one:

$ . .venv/bin/activate && pip install sqlite3 2>&1 | grep -E '^ERROR' | head -2
ERROR: Could not find a version that satisfies the requirement sqlite3 (from versions: none)
ERROR: No matching distribution found for sqlite3

uv fails the same way:

$ uv venv --quiet uvenv --python 3.13 && uvenv/bin/python -c 'import sqlite3, sys; print(sys.version.split()[0], sqlite3.sqlite_version)'
3.13.14 3.53.4
$ uv pip install --quiet --python uvenv/bin/python sqlite3 2>&1 | head -3
  × No solution found when resolving dependencies:
  ╰─▶ Because sqlite3 was not found in the package registry and you require
      sqlite3, we can conclude that your requirements are unsatisfiable.
$ otool -L $(uvenv/bin/python -c 'import _sqlite3; print(_sqlite3.__file__)') | grep libsqlite3
	/opt/homebrew/opt/sqlite/lib/libsqlite3.dylib (compatibility version 9.0.0, current version 9.6.0)

The first command in that output also shows where the version comes from. Python 3.13.14 reports the same SQLite 3.53.4 as Python 3.14.6, because on this Mac both link to Homebrew’s sqlite package.

Troubleshooting

  • No matching distribution found for sqlite3: remove sqlite3 from requirements.txt. The module needs no install.
  • The SQLite version is too old: the venv uses whatever SQLite its base Python links to. For Homebrew’s Python, that’s Homebrew’s sqlite package, so brew upgrade sqlite updates it (not executed here). For a Python that bundles its own SQLite, create the venv from a newer build of that Python.
  • The shell and Python report different versions: that’s normal. They’re separate copies of SQLite. Here the shell on the PATH is macOS’s own 3.51.0, while Python uses 3.53.4:
$ . .venv/bin/activate && which sqlite3 && sqlite3 --version | cut -d' ' -f1 && python -c 'import sqlite3; print(sqlite3.sqlite_version)'
/usr/bin/sqlite3
3.51.0
3.53.4
  • database is locked: two connections are writing to the same file at once. See database is locked.

Conclusion

A Python virtual environment has SQLite through the built-in sqlite3 module whenever its base Python was built with it. Check it with one import and skip pip install sqlite3. When you need a newer SQLite, update the library that base Python uses.

Further reading

Tested with Python 3.14.6 (SQLite 3.53.4) and uv 0.12.0 on macOS on 7 October 2026.