py-bson / bson

Independent BSON codec for Python that doesn't depend on MongoDB.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No dumps since 0.5.0 version

tangb opened this issue Β· comments

commented

My code uses dumps function and since last update (0.5.0), this function doesn't exist.
Is it possible to update documented sample ?

Thank you πŸ˜„

I will check.
Thanks for report

commented

It seems a module bson is installed with pymongo that overwrites your module content directory.
It's why I hadn't your module functions when I imported bson module while I had bson 0.5.0 installed.

I'm not using py-mongo and am able to reproduce this issue:

Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bson
>>> bson.dumps
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'bson' has no attribute 'dumps'
>>>
 ~ ξ‚° mkdir bson-test                                                                                                                                                                                                            (1s 433ms)
 ~ ξ‚° cd bson-test
 ~/bson-test ξ‚° python -m venv bson_test_venv .
 ~/bson-test ξ‚° . bin/activate.fish                                                                                                                                                                                              (5s 111ms)
(bson-test)  ~/bson-test ξ‚° pip install bson
Collecting bson
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/b9/42/e823b5f13515e3af308fb6efcacff456fc59078ec0e9ac426e842d66c9cb/bson-0.5.8.tar.gz
Collecting python-dateutil>=2.4.0 (from bson)
  Downloading https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl (226kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 235kB 658kB/s
Collecting six>=1.9.0 (from bson)
  Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil, bson
  Running setup.py install for bson ... done
Successfully installed bson-0.5.8 python-dateutil-2.8.0 six-1.12.0
You are using pip version 9.0.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(bson-test)  ~/bson-test ξ‚° python                                                                                                                                                                                               (5s 264ms)
Python 3.6.1 (default, Apr 19 2017, 20:04:37)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bson
>>> bson.dumps
<function dumps at 0x108dd8598>
>>> bson.dumps({'hello': 'world'})
b'\x16\x00\x00\x00\x02hello\x00\x06\x00\x00\x00world\x00\x00'
>>> exit()
(bson-test)  ~/bson-test ξ‚°

I just tired and couldn't reproduce. I will look for it more when get more information.

I'm getting this error with pymongo installed. Could you maybe pack it as a different name?

I will consider with pybson

That would be wonderful.

commented

In my case, I had a problem installing the pymongo package. It created ymong named file inside the venv/site-packages. I just deleted those and it worked ! These files probably starts with the ~ prefix