/home/mac126/.pyenv/versions/3.6.6/bin/python /home/mac126/Desktop/11/day1/mongo_cache.py
Traceback (most recent call last):
File "/home/mac126/Desktop/11/day1/mongo_cache.py", line 47, in <module>
mongo_cache = MongoCache()
File "/home/mac126/Desktop/11/day1/mongo_cache.py", line 17, in __init__
self.db.webpage.create_index('timestamp',expireAfterSeconds=expires.total_seconds())
File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/collection.py", line 1958, in create_index
self.__create_index(keys, kwargs, session, **cmd_options)
File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/collection.py", line 1847, in __create_index
with self._socket_for_writes() as sock_info:
File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/collection.py", line 196, in _socket_for_writes
return self.__database.client._socket_for_writes()
File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/mongo_client.py", line 1085, in _socket_for_writes
server = self._get_topology().select_server(writable_server_selector)
File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/topology.py", line 224, in select_server
address))
File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/topology.py", line 183, in select_servers
selector, server_timeout, address)
File "/home/mac126/.pyenv/versions/3.6.6/lib/python3.6/site-packages/pymongo/topology.py", line 199, in _select_servers_loop
self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused
Process finished with exit code 1
When you see a piece of red, you feel powerless. In fact, it’s very easy to solve problems one by one. You need to be patient to solve them one by one. First, you need to see what mistakes are reported, go to Baidu and try to solve problems by yourself. You can’t always ask others. Sometimes others are impatient. As a programmer, the most important thing is the ability to solve problems, Stop talking nonsense and start solving problems:
pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused
This error indicates that your database may not be open. Just open your database
cd /usr/local/mongoDB/mongodbserver/bin#Switch to your mongodb/bin directory
Enter.
. /mongod --dbpath . /
# Start the program
Similar Posts:
- [Solved] Python3 operate pymongo error: pymongo.errors.ConfigurationError
- [Solved] TypeError: ‘Collection’ object is not callable. If you meant to call the ‘authenticate’ method on a ‘Database’ object it is failing because no such method exists.
- [Solved] Python 3.9 Start Ride error: Attributeerror: ‘MenuItem’ object has no attribute ‘getlabel’
- How to Solve centos7 selenium–unknown error: DevToolsActivePort file doesn’t exist
- Strange frame error caused by incorrect use of flash. Redirect (‘/ path’) in flash
- [Solved] Runtime Warning: Font Glyph 20108 is missing. Font.set Fu text (s,0.0,flags=flags), RuntimeWarningGlyph20108missingfromcurrentfontfontsettexts00flagsflags
- Pyenv build failed solution
- How to Solve Error: [errno 99] cannot assign requested address error:
- You-get Warning urllib.error.URLError:
- Python AttributeError: ‘unicode’ object has no attribute ‘tzinfo’