2017-04-03 53 views
0

我最近在mac sierra上使用自制软件安装了mongodb,并且一切正常;从导入到连接。但是当我试图插入我得到了以下错误:pymongo在mac sierra插入错误

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Library/Python/2.7/site-packages/pymongo/collection.py", line 2467, in insert 
    with self._socket_for_writes() as sock_info: 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__ 
    return self.gen.next() 
    File "/Library/Python/2.7/site-packages/pymongo/mongo_client.py", line 823, in _get_socket 
    server = self._get_topology().select_server(selector) 
    File "/Library/Python/2.7/site-packages/pymongo/topology.py", line 214, in select_server 
    address)) 
    File "/Library/Python/2.7/site-packages/pymongo/topology.py", line 189, in select_servers 
    self._error_message(selector)) 
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: timed out 

我用pymongo 3.4.3,然后我降级到2.8,然后我去下面的连接时:

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Library/Python/2.7/site-packages/pymongo/mongo_client.py", line 377, in __init__ 
    raise ConnectionFailure(str(e)) pymongo.errors.ConnectionFailure: timed out 
+0

是否使用IPv6的本机连接? – lapinkoira

+0

不,我正在使用ipv4 localhost连接 – Golfexodus

回答

0

谢谢你们,我明白了,我意识到我的mongod实际上并不是从终端开始的。

我所要做的就是从终端开始的mongod像这样:

$ mongod的