poetry: TypeError unhashable type: 'Integer' installing dependencies using Poetry 1.5.1
- Poetry version: 1.5.1
- Python version: 3.11
- OS version and name:
python:3.11-slim-bullseye
Docker image - pyproject.toml:
[tool.poetry.dependencies]
python = "^3.10, <3.12"
typing_extensions = "*"
fastapi = "*"
uvicorn = { version = "*", extras = ["standard"] }
uvloop = { version = "*", markers = "sys_platform != 'win32'" }
psutil = "*"
httpx = ">=0.15.4, <0.24.0"
attrs = ">=21.3.0"
python-dateutil = "^2.8.0"
imageio = "*"
numpy = "*"
opencv-python-headless = ">4.5, <4.6"
Pillow = "*"
scipy = "*"
scikit-image = "*"
pydantic = "*"
pandas = "*"
tflite-runtime-nightly = { version = "*", markers = "sys_platform == 'linux'" }
tensorflow-macos = { version = "2.12.0", markers = "sys_platform == 'darwin'" }
tensorflow-cpu = { version = "*", markers = "sys_platform != 'linux' and sys_platform != 'darwin'" }
- I am on the latest stable Poetry version, installed using a recommended method.
- I have searched the issues of this repo and believe that this is not a duplicate.
- I have consulted the FAQ and blog for any relevant entries or release notes.
- If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option) and have included the output below.
Issue
As of today, installing Poetry 1.5.1 and running poetry install
in an python:3.11-slim-bullseye
Docker image build started throwing an exception.
FROM python:3.11-slim-bullseye
ENV POETRY_VERSION 1.5.1
ENV WORKDIR /src
WORKDIR ${WORKDIR}
RUN apt-get update && apt-get install -y \
python3-dev \
gcc \
&& rm -rf /var/lib/apt/lists/*
RUN pip install "poetry==${POETRY_VERSION}"
ENV VIRTUAL_ENV /opt/venv
RUN python -m venv ${VIRTUAL_ENV}
ENV PATH "${VIRTUAL_ENV}/bin:${PATH}"
COPY pyproject.toml poetry.lock ./
RUN poetry config installer.max-workers 4 && \
poetry install --only main --no-root
Error output:
#16 [processing_server python_builder 7/12] RUN poetry config installer.max-workers 4 && poetry install --only main --no-root
#16 1.038 Installing dependencies from lock file
#16 2.158
#16 2.158 Package operations: 39 installs, 0 updates, 0 removals
#16 2.158
#16 2.159 • Installing idna (3.4)
#16 2.159 • Installing sniffio (1.3.0)
#16 2.415
#16 2.415 TypeError
#16 2.415
#16 2.415 unhashable type: 'Integer'
#16 2.415
#16 2.415 at /usr/local/lib/python3.11/site-packages/urllib3/_collections.py:57 in __getitem__
#16 2.429 53│
#16 2.429 54│ def __getitem__(self, key):
#16 2.429 55│ # Re-insert the item, moving it to the end of the eviction line.
#16 2.429 56│ with self.lock:
#16 2.429 → 57│ item = self._container.pop(key)
#16 2.429 58│ self._container[key] = item
#16 2.429 59│ return item
#16 2.429 60│
#16 2.429 61│ def __setitem__(self, key, value):
#16 2.429
#16 2.432
#16 2.432 TypeError
#16 2.432
#16 2.432 unhashable type: 'Integer'
#16 2.432
#16 2.432 at /usr/local/lib/python3.11/site-packages/urllib3/_collections.py:57 in __getitem__
#16 2.441 53│
#16 2.441 54│ def __getitem__(self, key):
#16 2.441 55│ # Re-insert the item, moving it to the end of the eviction line.
#16 2.441 56│ with self.lock:
#16 2.441 → 57│ item = self._container.pop(key)
#16 2.441 58│ self._container[key] = item
#16 2.441 59│ return item
#16 2.441 60│
#16 2.441 61│ def __setitem__(self, key, value):
#16 2.441
#16 ERROR: process "/bin/sh -c poetry config installer.max-workers 4 && poetry install --only main --no-root" did not complete successfully: exit code: 1
------
> [processing_server python_builder 7/12] RUN poetry config installer.max-workers 4 && poetry install --only main --no-root:
2.441 53│
2.441 54│ def __getitem__(self, key):
2.441 55│ # Re-insert the item, moving it to the end of the eviction line.
2.441 56│ with self.lock:
2.441 → 57│ item = self._container.pop(key)
2.441 58│ self._container[key] = item
2.441 59│ return item
2.441 60│
2.441 61│ def __setitem__(self, key, value):
2.441
------
This same Dockerfile
worked yesterday, so I suspect that one of Poetry 1.5.1 sub-dependencies released a new version that might have broken something? Those aren’t locked for us (other than Poetry’s version itself).
I will try to see if I can track down what changed transitively recently if possible, a full output of the venv that Poetry is installed into:
#9 [python_builder 5/13] RUN pip list
#9 0.562 Package Version
#9 0.563 ------------------------- -----------
#9 0.563 attrs 23.1.0
#9 0.563 build 0.10.0
#9 0.564 CacheControl 0.12.14
#9 0.564 certifi 2023.7.22
#9 0.565 cffi 1.15.1
#9 0.565 charset-normalizer 3.2.0
#9 0.566 cleo 2.0.1
#9 0.567 crashtest 0.4.1
#9 0.567 cryptography 41.0.2
#9 0.567 distlib 0.3.7
#9 0.568 dulwich 0.21.5
#9 0.568 filelock 3.12.2
#9 0.569 html5lib 1.1
#9 0.570 idna 3.4
#9 0.570 importlib-metadata 6.8.0
#9 0.570 installer 0.7.0
#9 0.571 jaraco.classes 3.3.0
#9 0.571 jeepney 0.8.0
#9 0.572 jsonschema 4.18.4
#9 0.572 jsonschema-specifications 2023.7.1
#9 0.572 keyring 23.13.1
#9 0.573 lockfile 0.12.2
#9 0.573 more-itertools 10.0.0
#9 0.574 msgpack 1.0.5
#9 0.574 packaging 23.1
#9 0.575 pexpect 4.8.0
#9 0.576 pip 23.1.2
#9 0.576 pkginfo 1.9.6
#9 0.577 platformdirs 3.9.1
#9 0.577 poetry 1.5.1
#9 0.578 poetry-core 1.6.1
#9 0.578 poetry-plugin-export 1.4.0
#9 0.579 ptyprocess 0.7.0
#9 0.579 pycparser 2.21
#9 0.579 pyproject_hooks 1.0.0
#9 0.580 rapidfuzz 2.15.1
#9 0.580 referencing 0.30.0
#9 0.581 requests 2.31.0
#9 0.581 requests-toolbelt 1.0.0
#9 0.581 rpds-py 0.9.2
#9 0.582 SecretStorage 3.3.3
#9 0.582 setuptools 65.5.1
#9 0.582 shellingham 1.5.0.post1
#9 0.583 six 1.16.0
#9 0.583 tomlkit 0.12.0
#9 0.583 trove-classifiers 2023.7.6
#9 0.583 urllib3 1.26.16
#9 0.584 virtualenv 20.24.2
#9 0.584 webencodings 0.5.1
#9 0.584 wheel 0.40.0
#9 0.585 zipp 3.16.2
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 6
- Comments: 19 (12 by maintainers)
Isn’t it a bit ironical that poetry dependencies aren’t pinned? 😄
Sidenote, this issue is the kind of motivation I have for
Pinning “tomlkit < 0.12.0” solved it for us.
Same here, since today. Yesterday it was working as expected.
On my PC it is still working but start to fail today when tried to execute it inside the container. Seems like something in the OS (mine if Fedora 38) was changed and cause the issue.
Using poetry==1.4.2 works inside the container.
For me it works again, fix has been released at https://pypi.org/project/tomlkit/0.12.1/
Thanks, a quick fix will be released.
@aidanrussell-infogrid It might be because I omitted some
" "
, I’ve updated the answer. Thank you for the feedback.Just to say that for whatever reason the posted fix wouldn’t execute but if I tweaked it to this then it was resolved:
RUN pip install poetry==1.5.1 tomlkit==0.11.8
Many thanks @guigautier @johnthagen
@guigautier You beat me to it by a minute 😆
After searching them all, I found one offending package,
tomlkit
that had been released in the past 6 hours:A temporary workaround to address this issue: