Вот функция в которой возникает ошибка, при чем до этого все работало, что странно.
#Делает скриншот, сохраняет его и отправляет пользователю.
@bot.message_handler(commands = ["PrtSc"])
def prtsc(message):
if connection and message.from_user.id == id:
screen = pyautogui.screenshot('Images/screenshot1.png')
cv2Code.add_cursor('Images/screenshot1.png')
with open("Images/screenshot1.png", "rb") as screen:
bot.send_photo(message.chat.id, screen, timeout=10)
Файловая структура
Ошибки сразу 3
1)
Traceback (most recent call last):
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\urllib3\connectionpool.py", line 789, in urlopen
response = self._make_request(
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\urllib3\connectionpool.py", line 495, in _make_request
conn.request(
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\urllib3\connection.py", line 412, in request
self.send(chunk)
File "C:\Users\timof\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 992, in send
self.sock.sendall(data)
File "C:\Users\timof\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1236, in sendall
v = self.send(byte_view[count:])
File "C:\Users\timof\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1205, in send
return self._sslobj.write(data)
TimeoutError: The write operation timed out
2)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\requests\adapters.py", line 667, in send
resp = conn.urlopen(
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\urllib3\connectionpool.py", line 843, in urlopen
retries = retries.increment(
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\urllib3\util\retry.py", line 474, in increment
raise reraise(type(error), error, _stacktrace)
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\urllib3\util\util.py", line 38, in reraise
raise value.with_traceback(tb)
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\urllib3\connectionpool.py", line 789, in urlopen
response = self._make_request(
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\urllib3\connectionpool.py", line 495, in _make_request
conn.request(
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\urllib3\connection.py", line 412, in request
self.send(chunk)
File "C:\Users\timof\AppData\Local\Programs\Python\Python310\lib\http\client.py", line 992, in send
self.sock.sendall(data)
File "C:\Users\timof\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1236, in sendall
v = self.send(byte_view[count:])
File "C:\Users\timof\AppData\Local\Programs\Python\Python310\lib\ssl.py", line 1205, in send
return self._sslobj.write(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', TimeoutError('The write operation timed out'))
3)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Python\All\PyCharm\TelegrammPcControl\Bot.py", line 199, in <module>
bot.polling(none_stop=True,interval = 0,long_polling_timeout = 200)
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\telebot\__init__.py", line 1189, in polling
self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\telebot\__init__.py", line 1264, in __threaded_polling
raise e
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\telebot\__init__.py", line 1226, in __threaded_polling
self.worker_pool.raise_exceptions()
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\telebot\util.py", line 150, in raise_exceptions
raise self.exception_info
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\telebot\util.py", line 93, in run
task(*args, **kwargs)
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\telebot\__init__.py", line 8822, in _run_middlewares_and_handler
result = handler['function'](message)
File "D:\Python\All\PyCharm\TelegrammPcControl\Bot.py", line 97, in prtsc
bot.send_photo(message.chat.id, screen, timeout=10)
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\telebot\__init__.py", line 2250, in send_photo
apihelper.send_photo(
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\telebot\apihelper.py", line 527, in send_photo
return _make_request(token, method_url, params=payload, files=files, method='post')
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\telebot\apihelper.py", line 162, in _make_request
result = _get_req_session().request(
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "D:\Python\All\PyCharm\TelegrammPcControl\venv\lib\site-packages\requests\adapters.py", line 682, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError('The write operation timed out'))
Если я правильно понял, то по факту ошибки все об одном и том же, telebot не может отправить файл изображения, я подозреваю что дело в том что я неверно указал путь, хотя ничего конкретного найти не смог.
Файлы весят +- 500Кб что вообще ни о чем.
Помогите с этим делом пожалуйста, мне проект сдавать а тут такой косяк на ровном месте.