Pip Dependency Conflicts During Odoo Installation
When installing Odoo's Python dependencies, pip's resolver sometimes cannot find a compatible set of package versions. You see errors like:
ERROR: pip's dependency resolver does not currently consider all the packages that are installed.
ERROR: Cannot install odoo because these package versions have conflicting dependencies.
Werkzeug 3.0.1 requires MarkupSafe>=2.1.1, but you have MarkupSafe 1.1.1 which is incompatible.
lxml 5.1.0 requires libxml2>=2.9.2, but system has 2.9.1This typically happens when installing Odoo into an environment that already has other Python packages, or when the system Python is being used instead of a virtual environment.
Common Conflicting Packages
The most frequent dependency conflicts in Odoo installations involve these packages:
| Package | Odoo Needs | Conflict Source |
|---|---|---|
| Werkzeug | Specific range per version | Flask or other web frameworks |
| Jinja2 | >=3.1.2 | Older Ansible or Salt installations |
| lxml | >=4.9.0 | System-level lxml from apt |
| MarkupSafe | >=2.1.1 | Old Jinja2 dependency |
| psycopg2 | >=2.9 | psycopg2-binary already installed |
| Pillow | >=9.0 | Older system Pillow |
Step 1: Always Use a Virtual Environment
The number one cause of dependency conflicts is installing Odoo into the system Python. Create an isolated environment:
# Create a virtual environment
python3.12 -m venv /opt/odoo/venv
# Activate it
source /opt/odoo/venv/bin/activate
# Verify you're in the venv
which python # Should show /opt/odoo/venv/bin/python
# Now install Odoo requirements
pip install -r /opt/odoo/odoo/requirements.txtIf you already installed packages globally, start fresh with a new venv. Do not try to fix conflicts in the system Python.
Step 2: Upgrade pip and setuptools First
Older pip versions have a weaker dependency resolver that produces more conflicts:
# Upgrade pip itself
pip install --upgrade pip setuptools wheel
# Then install requirements
pip install -r requirements.txtPip versions below 23.0 are particularly problematic with complex dependency trees.
Step 3: Resolve Specific Package Conflicts
Werkzeug version mismatch:
# Error: Werkzeug>=3.0 required, but 2.x installed
pip install --force-reinstall Werkzeug==3.0.1
# Then re-run requirements
pip install -r requirements.txtpsycopg2 vs psycopg2-binary:
# These two packages conflict — you can only have one
pip uninstall psycopg2-binary psycopg2
# For development, use binary (easier):
pip install psycopg2-binary
# For production, compile from source (requires libpq-dev):
sudo apt install libpq-dev python3-dev
pip install psycopg2lxml build failures:
# Install system dependencies first
sudo apt install libxml2-dev libxslt1-dev zlib1g-dev
# Then install lxml
pip install lxmlStep 4: Use Constraint Files for Stubborn Conflicts
If pip cannot resolve dependencies automatically, create a constraints file:
# Create constraints.txt with exact versions
Werkzeug==3.0.1
Jinja2==3.1.3
MarkupSafe==2.1.5
lxml==5.1.0
Pillow==10.2.0# Install with constraints
pip install -r requirements.txt -c constraints.txtStep 5: Nuclear Option — Clean Reinstall
When nothing else works, rebuild the virtual environment from scratch:
# Deactivate current venv
deactivate
# Remove old venv
rm -rf /opt/odoo/venv
# Recreate
python3.12 -m venv /opt/odoo/venv
source /opt/odoo/venv/bin/activate
pip install --upgrade pip setuptools wheel
pip install -r /opt/odoo/odoo/requirements.txtDocker Environments
If you are running Odoo in Docker and see dependency conflicts during a custom build, ensure your Dockerfile installs requirements in the correct order:
FROM odoo:19
USER root
# Install system deps first
RUN apt-get update && apt-get install -y libxml2-dev libxslt1-dev
# Then Python packages
COPY requirements.txt /tmp/
RUN pip install --no-cache-dir -r /tmp/requirements.txt
USER odooPrevention
DeployMonkey provisions Odoo instances with pre-resolved dependency trees. The AI agent validates all package versions before deployment, eliminating pip conflicts entirely. No manual dependency management needed.