【发布时间】:2015-03-09 11:44:45
【问题描述】:
我在我的瓶子 virtualenv 中安装了 pymongo。我尝试使用它,但收到以下错误:
connection = Connection()
---------------------------------------------------------------------------
ConnectionFailure Traceback (most recent call last)
<ipython-input-9-609d5cb538f5> in <module>()
----> 1 connection = Connection()
/home/python/BENV/local/lib/python2.7/site-packages/pymongo/connection.pyc in __init__(self, host, port, max_pool_size, network_timeout, document_class, tz_aware, _connect, **kwargs)
234
235 super(Connection, self).__init__(host, port,
--> 236 max_pool_size, document_class, tz_aware, _connect, **kwargs)
237
238 def __repr__(self):
/home/python/BENV/local/lib/python2.7/site-packages/pymongo/mongo_client.pyc in __init__(self, host, port, max_pool_size, document_class, tz_aware, _connect, **kwargs)
367 except AutoReconnect, e:
368 # ConnectionFailure makes more sense here than AutoReconnect
--> 369 raise ConnectionFailure(str(e))
370
371 if username:
ConnectionFailure: [Errno 111] Connection refused
为什么会出现此错误,如何解决?
【问题讨论】:
-
你开始
mongod了吗? -
我只安装了pymongo,mongodb我们已经开始这样做了吗?
-
如果没有安装mongodb需要安装
sudo apt-get install mongodb -
netstat -an | grep mongodb输出什么?