我正在开发一个(python 2.7)flask-mongoengine 应用程序,它使用 bson 的 ObjectId。该项目以一种或另一种方式需要bson。我在尝试部署应用程序的主机上没有 root 访问权限,并且 pip install bson 失败:
-bash-4.1$ pip install bson
Collecting bson
Using cached bson-1.1.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-BBOawV/bson/setup.py", line 24, in <module>
import bson
File "bson/__init__.py", line 66, in <module>
from . import codec
File "bson/codec.py", line 28, in <module>
from .objects import *
File "bson/objects.py", line 36
class BSONObject(object, metaclass=ABCMeta):
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-BBOawV/bson/
另一方面,https ://api.mongodb.org/python/current/installation.html 声明我不应该使用这个版本的 bson 并依赖 pymongo 的实现。但是,在我安装了 pymongo-3.2.1 的计算机上,我无法导入 pymongo.objectId - 那么我做错了什么以及如何让 bson 使用我的设置?
非常感谢!