MongoEngine / mongoengine

A Python Object-Document-Mapper for working with MongoDB
http://mongoengine.org
MIT License
4.24k stars 1.23k forks source link

ImportError: cannot import name 'Connection' from 'pymongo' #1993

Closed domenicomonaco closed 5 years ago

domenicomonaco commented 5 years ago

I use MongoEngine with Pyhton3 and for initially I've installe pymongo==3.7.*, but I have this error message:

/usr/local/bin/python3 ...model.py
Traceback (most recent call last):
  File "/...model.py", line 3, in <module>
    from mongoengine import *
  File "/usr/local/lib/python3.7/site-packages/mongoengine/__init__.py", line 1, in <module>
    from . import document
  File "/usr/local/lib/python3.7/site-packages/mongoengine/document.py", line 12, in <module>
    from .connection import get_db, DEFAULT_CONNECTION_NAME
  File "/usr/local/lib/python3.7/site-packages/mongoengine/connection.py", line 2, in <module>
    from pymongo import Connection, ReplicaSetConnection, uri_parser
ImportError: cannot import name 'Connection' from 'pymongo' (/usr/local/lib/python3.7/site-packages/pymongo/__init__.py)

To resolve this I follow this https://stackoverflow.com/a/32218936/189411

bagerard commented 5 years ago

Hi @domenicomonaco, I can't replicate this with the latest version of mongoengine and from what I've seen it has been fixed in mongoengine/connection.py for a while. Which version of mongoengine are you using?

erdenezul commented 5 years ago

feel free to re-open problem still persists latests version of mongoengine

domenicomonaco commented 5 years ago

I don't know if is only my problem that depends by specific configuration and dependencies.