当我运行这样的代码时:
#!/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
输出是:
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
环境:
当我在windows8上运行代码时,它运行良好 但是在VPS(centos)上运行,总会出现问题
我使用pymongo 3.0.2,有这样的错误:pymongo.errors.ServerSelectionTimeoutError: No servers found yet
我无法解决,所以改为pymongo 2.8
但还是错了......
我希望有人可以帮助我。