首页 文章

如何从pipongo / mongoengine的pip中找到正确版本的bson

提问于
浏览
1

我正在使用bson的ObjectId(python 2.7)flask-mongoengine应用程序 . 该项目需要以一种或另一种方式使用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表示我不应该实施 . 但是,在我安装了pymongo-3.2.1的计算机上,我无法导入pymongo.objectId - 所以我做错了什么以及如何让bson与我的设置一起工作?

太谢谢了!

3 回答

  • 0

    我有类似的问题 .

    只需从https://pypi.python.org/pypi/bson/0.4.3下载tarball并进行手动安装:

    python setup.py install
    
  • 0

    由于我没有root访问权限且无法安装bson的发行版本,因此我选择将对象放在我的DB文档定义中 . 这解决了它,因为它也更清洁,但事实是Mihai说:pip install bson似乎仅限于python3项目 .

  • 0

    我有同样的问题,重新安装PyMongo修复了BSON依赖项:

    pip install --upgrade --force-reinstall pymongo
    

相关问题