Search code examples
pythondockerodooodoo-14

How to install cryptography library on Docker container?


I develop our company website with Odoo 14. I installed Odoo on my local machine (macOS Monterey (12.5.1)) via Docker. I use Docker Desktop and I have created docker-compose.yaml taking official Odoo docker image page as reference.

version: '2'
services:
  web:
    image: odoo:14.0
    depends_on:
      - db
    ports:
      - "8069:8069"
    volumes:
      - odoo-web-data:/var/lib/odoo©
      - ./config:/etc/odoo
      - ./addons:/mnt/extra-addons
  db:
    image: postgres:10
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_PASSWORD=odoo
      - POSTGRES_USER=odoo
      - PGDATA=/var/lib/postgresql/data/pgdata
    volumes:
      - odoo-db-data:/var/lib/postgresql/data/pgdata
      - ./db:/db
volumes:
  odoo-web-data:
  odoo-db-data:

I wanted to install Odoo eCommerce module but I couldn't. It gives that error:

Unable to install module "account_edi_proxy_client" because an external dependency is not met: Python library not installed: cryptography

I already installed it but it still gives the same error.

$ pip3 install cryptography
Requirement already satisfied: cryptography in /usr/local/lib/python3.10/site-packages (38.0.4)
Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.10/site-packages (from cryptography) (1.15.1)
Requirement already satisfied: pycparser in /usr/local/lib/python3.10/site-packages (from cffi>=1.12->cryptography) (2.21)

There were some suggestion to install pycryptodome instead, I installed it as well but still the same result.

After all, I realised that I was trying installing cryptography library on my local machine and actually I had to install it in the docker container.

So, I ran this command:

docker exec -it [container_name] pip3 install cryptography

and I got this error now:

Command "/usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-ynyd_o0_ --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools>=40.6.0,!=60.9.0 wheel "cffi>=1.12; platform_python_implementation != 'PyPy'" setuptools-rust>=0.11.4" failed with error code 1 in None

What is missing here, any idea?


Solution

  • Try to upgrade pip and setuptools first and then install cryptography

    docker exec -it CONTAINER_ID pip3 install --upgrade pip
    docker exec -it CONTAINER_ID pip3 install --upgrade setuptools
    
    docker exec -it CONTAINER_ID pip3 install cryptography