Installation¶
Requirements¶
Carbonic requires Python 3.12 or higher. It's designed to work with modern Python features and type annotations.
Installation Methods¶
PyPI Installation (Recommended)¶
Install the latest stable version from PyPI:
Development Installation¶
For the latest development version:
Poetry¶
If you're using Poetry for dependency management:
UV¶
If you're using UV for package management:
Optional Dependencies¶
Carbonic offers optional dependencies for enhanced functionality:
Performance Optimizations (Recommended)¶
For significantly faster ISO datetime parsing and other performance improvements:
This installs ciso8601, which provides C-accelerated ISO datetime parsing that's ~10x faster than the standard library, plus enables other performance optimizations like lazy evaluation caching.
Pydantic Integration¶
For data validation and serialization with Pydantic:
This enables custom Pydantic field types for all Carbonic datetime classes, allowing seamless integration with FastAPI, SQLModel, and other Pydantic-based frameworks.
Development¶
For development and contributing:
This includes testing, linting, documentation, and type checking tools.
All Optional Dependencies¶
To install everything:
Verify Installation¶
Verify that Carbonic is installed correctly:
import carbonic
print(carbonic.__version__)
# Test basic functionality
from carbonic import now, DateTime
current_time = now()
print(f"Current time: {current_time}")
dt = DateTime(2025, 1, 15, 14, 30)
print(f"Example datetime: {dt.format('Y-m-d H:i:s')}")
Expected output:
Troubleshooting¶
ImportError: No module named 'carbonic'¶
This usually means the installation failed or you're using the wrong Python environment:
- Check your Python version: python --version
- Verify pip is working: pip --version
- Try reinstalling: pip uninstall carbonic && pip install carbonic
- Check virtual environment: which pythonandwhich pip
ModuleNotFoundError: No module named 'zoneinfo'¶
This should not happen with Python 3.12+, but if you see this error:
- Verify your Python version: python --version
- Update Python to 3.12 or higher
- If using an older Python version, install the backport: pip install backports.zoneinfo
Performance Issues¶
If datetime parsing is slow:
- Install the performance extra: pip install carbonic[performance]
- Verify ciso8601 is installed: pip list | grep ciso8601
Type Checking Issues¶
If you're using mypy and seeing type errors:
- Ensure you have the latest version: pip install --upgrade carbonic
- Check mypy configuration for PEP 561 support
- Verify you're using a supported Python version (3.12+)
Next Steps¶
Now that you have Carbonic installed, continue with:
- Quick Start Guide - Get up and running quickly
- Core Concepts - Understand the fundamental principles
- User Guide - Dive into specific features