此错误可能是什么原因?我在Windows 10主机系统中使用ubuntu来宾服务器
整个错误如下:
` File "train_data.py", line 36, in <module>
update_database.insert_features(features)
File "/pupyl/preprocessing_data/update_database_with_features.py", line 59, in insert_features
self.db_operation.insert_record(records, "train")
File "/pupyl/database_client/database_operations.py", line 33, in insert_record
self.db.train.insert(record)
File "/usr/local/lib/python3.6/site-packages/pymongo/collection.py", line 3161, in insert
check_keys, manipulate, write_concern)
File "/usr/local/lib/python3.6/site-packages/pymongo/collection.py", line 607, in _insert
bypass_doc_val, session)
File "/usr/local/lib/python3.6/site-packages/pymongo/collection.py", line 595, in _insert_one
acknowledged, _insert_command, session)
File "/usr/local/lib/python3.6/site-packages/pymongo/mongo_client.py", line 1242, in _retryable_write
with self._tmp_session(session) as s:
File "/usr/local/lib/python3.6/contextlib.py", line 81, in __enter__
return next(self.gen)
File "/usr/local/lib/python3.6/site-packages/pymongo/mongo_client.py", line 1571, in _tmp_session
s = self._ensure_session(session)
File "/usr/local/lib/python3.6/site-packages/pymongo/mongo_client.py", line 1558, in _ensure_session
return self.__start_session(True, causal_consistency=False)
File "/usr/local/lib/python3.6/site-packages/pymongo/mongo_client.py", line 1511, in __start_session
server_session = self._get_server_session()
File "/usr/local/lib/python3.6/site-packages/pymongo/mongo_client.py", line 1544, in _get_server_session
return self._topology.get_server_session()
File "/usr/local/lib/python3.6/site-packages/pymongo/topology.py", line 427, in get_server_session
None)
File "/usr/local/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
`
train_data.py如下所示,如果有帮助的话:
features: Tuple[List[str], List[str], List[str], List[bool], List[str]] = \
extract_features.separation_of_features(parsed_json)
update_database.insert_features(features)
答案 0 :(得分:0)
似乎您的应用程序无法连接到数据库,请验证数据库是否实际上在localhost:27017上运行并接受连接 ps:尝试与mongoshell连接