File "C:\Users\****\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\__init__.py", line 87, in <module>
from pymongo import _csot
File "C:\Users\****\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\_csot.py", line 22, in <module>
from pymongo.write_concern import WriteConcern
File "C:\Users\****\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\write_concern.py", line 19, in <module>
from pymongo.errors import ConfigurationError
File "C:\Users\****\AppData\Local\Programs\Python\Python310\lib\site-packages\pymongo\errors.py", line 18, in <module>
from bson.errors import InvalidDocument
ModuleNotFoundError: No module named 'bson'
I’ve spent hours trying to figure this out, any help would be greatly appreciated.
@shane 's answer is clear about the package. however, I want to add some other things.
new versions of some libraries versus the version of python installation has always its problems. a new library version may not have compiled binaries for old python, or a new/old library may not be compiled yet for new python. In such cases, the installer tries to use a system C compiler (CPython at least) and compile the library for the python of the currently active environment.
emphasis is on the “version” and “active”. You guys might be forgetting to change activate/switch environments at times, which gives different results every time you try.
Or maybe, as the lines get longer, you might be ignoring/missing possible compile errors on the way. so the actual library you were expecting might not even be there. This is very common in windows systems as compilers are not easy to install/manage.
Two things are important when you start having problems: make sure you are in the right environment, and check the installation result. A new/clear virtual environment with a suitable python version is mostly the best solution.
PS: pymongo 4.3.3, currently latest, has wheels for python 3.7 and later for most distributions, and a compile should be triggered for previous python versions, whereas 4.2.0 does not have any for python 3.11 which also should trigger a compile.