[英]pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 61] Connection refused
I am learning to use pymongo, but I get stuck on the intro code from this website https://realpython.com/introduction-to-mongodb-and-python/#sql-vs-nosql : 我正在学习使用pymongo,但是我陷入了该网站https://realpython.com/introduction-to-mongodb-and-python/#sql-vs-nosql的介绍代码中:
from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.pymongo_test
posts = db.posts
post_data = {'title': 'Python and MongoDB'}
result = posts.insert_one(post_data)
After the last line, I get the error in the header. 最后一行之后,我在标题中得到了错误。 I have no experience with databases, so I have no idea where to start debugging this.
我没有数据库方面的经验,所以我不知道从哪里开始调试它。
I am using Python 3.7.3, pymongo 3.7.2 and mongodb 4.0.3 on a Mac OS X. 我在Mac OS X上使用Python 3.7.3,pymongo 3.7.2和mongodb 4.0.3。
刚发现-我认为只需在Anaconda上安装mongodb软件包就足够了,但是我必须使用brew正确安装MongoDB。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.