Flask ImportError with bson on OS X

霸气de小男生 提交于 2019-11-30 11:07:48

Try uninstalling the bson and pymongo packages and then reinstalling the pymongo package. pymongo installs its own bson package and I think you've overwritten it with the other bson package installation and that is probably what is causing your import error.

I met the same problem. I think the reason is I install pymongo and then install bson. Then I uninstall bson. Then I got this problem.

pip freeze pymongo it requires Nothing.

So maybe it has its own bson package.

What I solve this problem:

pip uninstall pymongo

pip uninstall bson

and then reinstall pymongo

pip install pymongo

You are returning a list in hello(). You need to return a string or a Response object, see Flask docs. E.g. convert the list to a string before returning:

return '\n'.join(json_docs)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!