-2

from pymongo import MongoClient

I use the mongoDB to store my data, python version 3.10 , mongoDB the latest. But I kept getting the error:

`from collections import MutableMapping, namedtuple ImportError: cannot import name 'MutableMapping' from 'collections'

I tried to add

from collections.abc import MutableMapping

But always not worked

I tried to update the python to the verion 3.11 by creating another virtual environment, it worked anyway.enter image description here

Then I exit the current working terminal in pycharm, and restart it. and switch to the new venvn virtual environment. But have to install packages again, like scrapy, pymongo, "pymongo[srv]" etc.

user2357112
  • 260,549
  • 28
  • 431
  • 505

1 Answers1

0

This should work; check your virtual environment:

from collections.abc import MutableMapping

Link : https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping

Talha Tayyab
  • 8,111
  • 25
  • 27
  • 44