How to Install freezegun in Python
Let your Python tests travel through time
pip install freezegun
What is freezegun?
Let your Python tests travel through time
FreezeGun: Let your Python tests travel through time
FreezeGun is a library that allows your Python tests to travel through time by mocking the datetime module.
Once the decorator or context manager have been invoked, all calls to datetime.datetime.now(), datetime.datetime.utcnow(), datetime.date.today(), time.time(), time.localtime(), time.gmtime(), and time.strftime() will return the time that has been frozen. time.monotonic() and time.perfcounter() will also be frozen, but as usual it makes no guarantees about their absolute value, only their changes over time.
Quick Start
Minimal example to get started with freezegun:
import freezegun
print(freezegun.__version__)
Installation
pip (standard)
pip install freezegun
Virtual environment (recommended)
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install freezegun
pip3
pip3 install freezegun
conda
conda install -c conda-forge freezegun
Poetry
poetry add freezegun
Dependencies
Installing freezegun will also install these packages:
Verify the Installation
After installing, confirm the package is available:
python -c "import freezegun; print(freezegun.__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 freezegun with pip.
ModuleNotFoundError: No module named 'freezegun'
Cause: The package is not installed in the current Python environment.
Fix: Run pip install freezegun. If using a virtual environment, ensure it is activated first.
ModuleNotFoundError: No module named 'freezegun' (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 freezegun to install into the interpreter you are running.
ImportError: cannot import name 'X' from 'freezegun'
Cause: The function or class does not exist in the installed version.
Fix: Check the version with pip show freezegun and upgrade with pip install --upgrade freezegun.
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 freezegun. 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 freezegun
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 freezegun
Recent Releases
| Version | Released |
|---|---|
1.5.5 latest |
2025-08-09 |
1.5.4 |
2025-07-30 |
1.5.3 |
2025-07-12 |
1.5.2 |
2025-05-24 |
1.5.1 |
2024-05-11 |
Manage freezegun
Upgrade to latest version
pip install --upgrade freezegun
Install a specific version
pip install freezegun==1.5.5
Uninstall
pip uninstall freezegun
Check what is installed
pip show freezegun