30
30
[GCC 4.5.3] on linux2
31
31
Type "help", "copyright", "credits" or "license" for more information.
33
>>> c = pymongo.Connection()
33
>>> c = pymongo.MongoClient()
34
34
>>> c.test.bintest.insert({'binary': b'this is a byte string'})
35
35
ObjectId('4f9086b1fba5222021000000')
36
36
>>> c.test.bintest.find_one()
43
43
[GCC 4.5.3] on linux2
44
44
Type "help", "copyright", "credits" or "license" for more information.
46
>>> c = pymongo.Connection()
46
>>> c = pymongo.MongoClient()
47
47
>>> c.test.bintest.find_one()
48
48
{u'binary': Binary('this is a byte string', 0), u'_id': ObjectId('4f9086b1fba5222021000000')}
151
151
will be the first thing in your path. Importing pymongo will result in an
152
152
exception similar to::
154
Python 3.1.4 (default, Mar 21 2012, 14:34:01)
155
[GCC 4.5.3] on linux2
154
Python 3.1.5 (default, Jun 2 2012, 12:24:49)
155
[GCC 4.6.3] on linux2
156
156
Type "help", "copyright", "credits" or "license" for more information.
157
157
>>> import pymongo
158
158
Traceback (most recent call last):
159
159
File "<stdin>", line 1, in <module>
160
File "pymongo/__init__.py", line 104, in <module>
161
from pymongo.connection import Connection
162
File "pymongo/connection.py", line 573
163
except Exception, why:
165
SyntaxError: invalid syntax
160
File "pymongo/__init__.py", line 58, in <module>
161
version = get_version_string()
162
File "pymongo/__init__.py", line 54, in get_version_string
163
if isinstance(version_tuple[-1], basestring):
164
NameError: global name 'basestring' is not defined
167
166
Note the path in the traceback (``pymongo/__init__.py``). Changing out of the
168
167
source directory takes the untranslated modules out of your path::
172
Python 3.1.4 (default, Mar 21 2012, 14:34:01)
173
[GCC 4.5.3] on linux2
171
Python 3.1.5 (default, Jun 2 2012, 12:24:49)
172
[GCC 4.6.3] on linux2
174
173
Type "help", "copyright", "credits" or "license" for more information.
175
174
>>> import pymongo
176
175
>>> pymongo.__file__