Moonwalker
Moonwalker

Reputation: 2232

Cannot import pymongo while pymongo installed and runs fine in some other scripts

On my ubuntu 12.04 machine I have several other scripts (which are using pymongo) running fine in screens. But then I try to run another script or just import pymongo in python console I get this:

> >>> from pymongo import Connection 
> Traceback (most recent call last):   File "<stdin>", line 1, in <module>   File
> "/usr/local/lib/python2.7/dist-packages/pymongo/__init__.py", line 60,
> in <module>
>     from pymongo.connection import Connection   File "/usr/local/lib/python2.7/dist-packages/pymongo/connection.py", line
> 39, in <module>
>     from pymongo.mongo_client import MongoClient   File "/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py", line
> 44, in <module>
>     from bson.py3compat import b   File "/usr/local/lib/python2.7/dist-packages/bson/__init__.py", line 27, in
> <module>
>     from bson.dbref import DBRef   File "/usr/local/lib/python2.7/dist-packages/bson/dbref.py", line 17, in
> <module>
>     from copy import deepcopy   File "copy.py", line 2, in <module>
>     connection = pymongo.Connection('localhost', 27017) AttributeError: 'module' object has no attribute 'Connection'
> >>>

Importing installed module fails for unknown reason.

While already running scripts keep running fine, I cannot start any new ones which are using pymongo.

I'm completely lost here, don't know what to do (and cannot google anything useful).

Upvotes: 0

Views: 1962

Answers (1)

Moonwalker
Moonwalker

Reputation: 2232

Oh, it turned out I've created file copy.py in the folder with the script which became used by pymongo instead of original python library.

I've been struggling for this the whole morning, but just asking a question here helped.

Upvotes: 3

Related Questions