尝试将 Colab Notebook 连接到 Atlas 上的 MongoDB。
from pymongo import MongoClient
uri = "mongodb+srv://MYUSERNAME:mypassword@mydatabase.mongodb.net/test"
client = MongoClient(uri)
Run Code Online (Sandbox Code Playgroud)
我收到一个配置错误:
"dnspython" module must be installed to use mongodb+srv:// URIs.
Run Code Online (Sandbox Code Playgroud)
我安装了模块。
pip install dnspython
Run Code Online (Sandbox Code Playgroud)
收到回消息
Requirement already satisfied: dnspython in /usr/local/lib/python3.6/dist-packages (1.16.0)
Run Code Online (Sandbox Code Playgroud)
不知道怎么回事。
几天前,这与另一个 colab 笔记本(和另一个数据库)一起工作。
这是整个错误消息:
ConfigurationError Traceback (most recent call last)
<ipython-input-30-a6c89e14e64f> in <module>()
----> 1 client = MongoClient(uri)
1 frames
/usr/local/lib/python3.6/dist-packages/pymongo/mongo_client.py in __init__(self, host, port, document_class, tz_aware, connect, type_registry, **kwargs)
522 for entity in host:
523 if "://" in entity: …Run Code Online (Sandbox Code Playgroud)