两个不同的 bson 模块的名称冲突 - 如何在同一脚本中同时使用 pymongo 的 bson 模块和 bson 的 bson 模块?

Name clash of two different bson modules - How can I use both pymongo's bson module and bson's bson module in the same script?

如何避免 pymongo 的 bson 模块和 bson 的(GitHub 上的 py-bson)bson 模块的名称冲突?

安装 bson 包作为 pybson , 见 https://github.com/py-bson/bson/issues/70.

我用过

pip uninstall bson

pip install pybson

现在这样我就可以使用了

import pybson as bson

当我想要回旧名称时。如果我不小心同时需要 pymongopybsonimport bson,我可以用别名。