TypeError: unhashable type: 'Path' (Importing any package)
I've got a weird one here. I've setup a mini Django project, and in the urls.py file, if I try any "from package import X", it results in an exception: TypeError: unhashable type: 'Path'
With no imports in this file, it all works perfectly and the server starts etc.
File "/app/app/urls.py", line 2, in <module>
2023-01-21T04:41:15.890469838Z from rest_framework.response import Response
2023-01-21T04:41:15.890486088Z File "/usr/local/lib/python3.8/site-packages/rest_framework/response.py", line 11, in <module>
2023-01-21T04:41:15.890490338Z from rest_framework.serializers import Serializer
2023-01-21T04:41:15.890492504Z File "/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py", line 27, in <module>
2023-01-21T04:41:15.890516629Z from rest_framework.compat import postgres_fields
2023-01-21T04:41:15.890534421Z File "/usr/local/lib/python3.8/site-packages/rest_framework/compat.py", line 33, in <module>
2023-01-21T04:41:15.890571546Z import coreapi
2023-01-21T04:41:15.890591004Z File "/usr/local/lib/python3.8/site-packages/coreapi/__init__.py", line 2, in <module>
2023-01-21T04:41:15.890598088Z from coreapi import auth, codecs, exceptions, transports, utils
2023-01-21T04:41:15.890600588Z File "/usr/local/lib/python3.8/site-packages/coreapi/auth.py", line 1, in <module>
2023-01-21T04:41:15.890602963Z from coreapi.utils import domain_matches
2023-01-21T04:41:15.890605254Z File "/usr/local/lib/python3.8/site-packages/coreapi/utils.py", line 5, in <module>
2023-01-21T04:41:15.890724213Z import pkg_resources
2023-01-21T04:41:15.890736088Z File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3249, in <module>
2023-01-21T04:41:15.891071296Z def _initialize_master_working_set():
2023-01-21T04:41:15.891081671Z File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3223, in _call_aside
2023-01-21T04:41:15.891363838Z f(*args, **kwargs)
2023-01-21T04:41:15.891371088Z File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3261, in _initialize_master_working_set
2023-01-21T04:41:15.891722921Z working_set = WorkingSet._build_master()
2023-01-21T04:41:15.891733421Z File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 608, in _build_master
2023-01-21T04:41:15.891780379Z ws = cls()
2023-01-21T04:41:15.891790796Z File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 601, in __init__
2023-01-21T04:41:15.891883463Z self.add_entry(entry)
2023-01-21T04:41:15.891889546Z File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 655, in add_entry
2023-01-21T04:41:15.892080713Z self.entry_keys.setdefault(entry, [])
2023-01-21T04:41:15.892097713Z TypeError: unhashable type: 'Path'
This is dockerised.
FROM python:3.8-slim
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY ./services/shared/requirements.txt /requirements/base.txt
COPY ./services/auth/requirements.txt /requirements/requirements.txt
RUN apt-get update \
&& apt-get install -y libjpeg62-turbo-dev zlib1g-dev ca-certificates gcc \
postgresql-client sed xmlsec1 pax-utils build-essential \
python-setuptools libpq-dev \
&& apt-get clean
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r /requirements/requirements.txt \
&& find /usr/local \
\( -type d -a -name test -o -name tests \) \
-o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
-exec rm -rf '{}' +
# Copy requirements and install local one
RUN rm -rf /requirements
I've never come across this before, although this is the first time I'm doing experimenting with sharing Django code across smaller independent container services.
Any help would be greatly appreciated. I see that something around coreapi dies, and no matter what I import, coreapi seems to be there as the last thing trying to import pkg_resources - but I can't figure out why?