pip install --no-cache-dir -r requirements.txt 报错ImportError: cannot import name '_get_object_size' from 'bson' (/usr/local/lib/python3.11/site-packages/bson/__init__.py)
错误如下:
Traceback (most recent call last): 2023-08-23 10:29:47 File "/app/main.py", line 12, in <module> 2023-08-23 10:29:47 from base.MongoDb import MongoDb 2023-08-23 10:29:47 File "/app/base/MongoDb.py", line 1, in <module> 2023-08-23 10:29:47 import pymongo 2023-08-23 10:29:47 File "/usr/local/lib/python3.11/site-packages/pymongo/__init__.py", line 89, in <module> 2023-08-23 10:29:47 from pymongo.collection import ReturnDocument 2023-08-23 10:29:47 File "/usr/local/lib/python3.11/site-packages/pymongo/collection.py", line 35, in <module> 2023-08-23 10:29:47 from bson.raw_bson import RawBSONDocument 2023-08-23 10:29:47 File "/usr/local/lib/python3.11/site-packages/bson/raw_bson.py", line 56, in <module> 2023-08-23 10:29:47 from bson import _get_object_size, _raw_to_dict 2023-08-23 10:29:47 ImportError: cannot import name '_get_object_size' from 'bson' (/usr/local/lib/python3.11/site-packages/bson/__init__.py)
原因 pymongo 已经包含了bson,如果再安装bson就会提示冲突,把文件中的#bson==0.5.10注释掉