When I run code like this:
#!/bin/env python
#encoding:utf-8
import sys
sys.path.append('/usr/lib64/python2.7/site-packages')
print sys.path
from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.guping
the output is:
Traceback (most recent call last):
File "test_mongo.py", line 8, in <module>
client = MongoClient('localhost', 27017)
File "/usr/lib64/python2.7/site-packages/pymongo/mongo_client.py", line 374, in __init__
self._ensure_connected(True)
File "/usr/lib64/python2.7/site-packages/pymongo/mongo_client.py", line 939, in _ensure_connected
self.__ensure_member()
File "/usr/lib64/python2.7/site-packages/pymongo/mongo_client.py", line 813, in __ensure_member
member, nodes = self.__find_node()
File "/usr/lib64/python2.7/site-packages/pymongo/mongo_client.py", line 873, in __find_node
member, nodes = self.__try_node(candidate)
File "/usr/lib64/python2.7/site-packages/pymongo/mongo_client.py", line 720, in __try_node
{'ismaster': 1})
File "/usr/lib64/python2.7/site-packages/pymongo/mongo_client.py", line 703, in __simple_command
helpers._check_command_response(response, None, msg)
File "/usr/lib64/python2.7/site-packages/pymongo/helpers.py", line 133, in _check_command_response
response)
pymongo.errors.OperationFailure: None
The env:
- python 2.7
- pymongo 2.8
When I run the code on windows8, it's worked well but run on VPS(centos),there is always something wrong
I use pymongo 3.0.2 , there is a error like this: pymongo.errors.ServerSelectionTimeoutError: No servers found yet
I can't solve it, so change to pymongo 2.8
But there still err...
I hope someone can help me.