pymongo - mongodb+srv “dnspython must be installed” error

后端 未结 7 2084
再見小時候
再見小時候 2020-12-28 13:35

I am trying to connect MongoDB from Atlas But I encountered:

dnspython must be installed error

My mongo uri (mo

相关标签:
7条回答
  • 2020-12-28 13:56

    In order to use mongo+srv protocol, you need to install pymongo-srv Launch this command to do it with python 3:

    pip3 install pymongo[srv]
    

    or this one for other versions:

    pip install pymongo[srv]
    

    And as @lukrebs suggested, for ZSH, add quotes:

    pip3 install 'pymongo[srv]'
    
    0 讨论(0)
  • 2020-12-28 13:57

    May be the protocol, your URI should start with:

    mongo+srv instead of mongo+src

    If it still not working please put a pip list with the versions of PyMongo and dnspython (and version of python that you are using)

    0 讨论(0)
  • 2020-12-28 14:02

    In requirements.txt, replace pymongo with pymongo[tls,srv], as mentioned here.

    0 讨论(0)
  • 2020-12-28 14:05

    I would like to answer my own questions here. As I mentioned in the comment, the kernel of the jupyter notebook has to be restarted in order for the pymongo to take effect of the loaded dnspython.

    0 讨论(0)
  • 2020-12-28 14:06

    you can use mongo:// instead of mongodb+srv://

    0 讨论(0)
  • 2020-12-28 14:10

    I solved this problem with:

    $ python -m pip install pymongo[srv]

    0 讨论(0)
提交回复
热议问题