Bohulenkov Artem
Bohulenkov Artem

Reputation: 59

python import pymongo fails

I've some strange thing with pymongo - yesterday my code worked just fine, by today i got an error while importing pymongo module(this error pops both in IDE and interpreter, and with using virtualenv):

>>> import pymongo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/bohulenkov14/my_new_env/lib/python2.7/site-packages/pymongo/__init__.py", line 61, in <module>
from pymongo.connection import Connection
File "/Users/bohulenkov14/my_new_env/lib/python2.7/site-packages/pymongo/connection.py", line 44, in <module>
from bson.py3compat import b
File "/Users/bohulenkov14/my_new_env/lib/python2.7/site-packages/bson/__init__.py", line 33, in <module>
from bson.objectid import ObjectId
File "/Users/bohulenkov14/my_new_env/lib/python2.7/site-packages/bson/objectid.py", line 51, in <module>
class ObjectId(object):
File "/Users/bohulenkov14/my_new_env/lib/python2.7/site-packages/bson/objectid.py", line 58, in ObjectId
_machine_bytes = _machine_bytes()
File "/Users/bohulenkov14/my_new_env/lib/python2.7/site-packages/bson/objectid.py", line 47, in _machine_bytes
machine_hash.update(socket.gethostname().encode())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

My OS - Mac OS X version 10.7.5. Pymongo was installed with easy_install.

I have a guess about the reason of this - I have windows installed on the same drive with mac os (installed with boot camp assistance) and i browsed with explorer some mac os directores before switching back on mac. Maybe it change some encodings anywhere, but i doubt it. I tried it Anybody know what could have happened with pymongo or macos, and how can i fix this ?

Upvotes: 2

Views: 486

Answers (1)

viktor
viktor

Reputation: 46

Hi a had the same error but on Windows.

when I write import pymongo -> I received unicodedecodeerror

My solution: change the name of pc to English, it was in russian (

Upvotes: 3

Related Questions