最近使用bson的json_util時出現錯誤。
錯誤提示如下:
ImportError: cannot import name 'json_util' from 'bson'
OR
ImportError: No module named 'bson.json_util'
經查閱資料發現bson庫依賴pymongo,才能正常使用,隨pip install pymongo
。安裝後正常,使用。
Python 3.7.6 (default, Jan 8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import bson.json_util
>>> from bson import json_util
>>>