How to Install cachetools in Python
Extensible memoizing collections and decorators
pip install cachetools
What is cachetools?
Extensible memoizing collections and decorators
This module provides various memoizing collections and decorators, including variants of the Python Standard Library's function decorator.
from cachetools import cached, LRUCache, TTLCache
# speed up calculating Fibonacci numbers with dynamic programming @cached(cache={}) def fib(n): return n if n < 2 else fib(n - 1) + fib(n - 2)
Quick Start
Minimal example to get started with cachetools:
import cachetools
print(cachetools.__version__)
Installation
pip (standard)
pip install cachetools
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install cachetools
pip3
pip3 install cachetools
conda
conda install -c conda-forge cachetools
Poetry
poetry add cachetools
Verify the Installation
After installing, confirm the package is available:
python -c "import cachetools; print(cachetools.__version__)"
If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.
Installation Errors
Common errors when installing cachetools with pip.
ModuleNotFoundError: No module named 'cachetools'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install cachetools. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'cachetools' (installed but still failing)
Cause: pip installed the package into a different Python than the one running your script.
Fix: Use python -m pip install cachetools to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'cachetools'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show cachetools and upgrade with pip install --upgrade cachetools.
pip: command not found
Cause: pip is not in PATH or Python was not added to PATH during installation.
Fix: Try python -m pip install cachetools. On macOS/Linux try pip3.
PermissionError: [Errno 13] Permission denied
Cause: No write access to the system Python package directory.
Fix: Use a virtual environment, or add --user: pip install --user cachetools
SSL: CERTIFICATE_VERIFY_FAILED
Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.
Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org cachetools
Recent Releases
| Version | Released |
|---|---|
7.0.5 latest |
2026-03-09 |
7.0.4 |
2026-03-08 |
7.0.3 |
2026-03-05 |
7.0.2 |
2026-03-02 |
7.0.1 |
2026-02-10 |
Manage cachetools
Upgrade to latest version
pip install --upgrade cachetools
Install a specific version
pip install cachetools==7.0.5
Uninstall
pip uninstall cachetools
Check what is installed
pip show cachetools