pytest-django
pytest-django copied to clipboard
ImportError: cannot import name 'Mapping' from 'collections' (/usr/local/lib/python3.10/collections/__init__.py)
Hi,
We are facing this issue when building a django project in docker env with docker-compose build command
ImportError: cannot import name 'Mapping' from 'collections' (/usr/local/lib/python3.10/collections/__init__.py)
pytest-django found a Django project in . (it contains manage.py) and added it to the Python path.
If this is wrong, add "django_find_project = false" to pytest.ini and explicitly manage your Python path.
In the following situation :
- Docker image
python:3.10.1-slim-buster pytest-django="==4.5.2"pytest="==6.2.5"
Thank's in advance
pytest-django does not try to import Mapping from collections, so the problem is not in this project. You'll need to find which code performs this import. You can search for a line such as from collections import Mapping (it might not be that exactly).
Thank's @bluetech for your reply 👍
I already checked that but there is no such import in the project's code 🤔
If you are using a virtualenv, check inside the virtualenv directory as well. This will tell you if any dependency is importing it.
I'm also getting this error, and I can't figure out what's doing it. I've searched for the string from collections import Mapping and I have no examples. Is there a way to stub this out such that an import succeeds and dies. It's horrible that the stacktrace here is so bad. Not sure what's responsible for that, core python or django but I would expect for an import failed to tell me where the caller was.