Подскажите как исправить проблему с само закрытием скрипта

Делал небольшой скрип для управления пк с помощью telegram bot. Но вот когда запускал программу в не среды IDE. Попробовал по совету D. Violet запустить фаил через cmd. Все заработало, но раз через раз вылезает такая ошибка.

C:\Users\илья>C:\Users\tegram.py 2020-04-27 23:55:38,890 (util.py:66 WorkerThread2) ERROR - TeleBot: "ConnectTimeout occurred, args=(MaxRetryError("HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /botТОКЕН/sendMessage?chat_id=482347840&text=%D0%A5%D0%BE%D1%80%D0%BE%D1%88%D0%BE%2C+%D0%B2%D1%8B%D0%B1%D0%B8%D1%80%D0%B0%D0%B9+%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D1%83&reply_markup=%7B%22keyboard%22%3A+%5B%5B%7B%22text%22%3A+%22Discord%22%7D%2C+%7B%22text%22%3A+%22Telegram%22%7D%2C+%7B%22text%22%3A+%22MediaGet%22%7D%5D%2C+%5B%7B%22text%22%3A+%22FPSMonitor%22%7D%2C+%7B%22text%22%3A+%22AIDA64%22%7D%2C+%7B%22text%22%3A+%22PyCharm%22%7D%5D%2C+%5B%7B%22text%22%3A+%22Skype%22%7D%2C+%7B%22text%22%3A+%22Chrome%22%7D%2C+%7B%22text%22%3A+%22Steam%22%7D%5D%2C+%5B%7B%22text%22%3A+%22%5Cu043c%5Cu0435%5Cu043d%5Cu044e%22%7D%5D%5D%7D (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x04587B80>, 'Connection to api.telegram.org timed out. (connect timeout=3.5)'))"),) Traceback (most recent call last):   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 156, in _new_conn
    conn = connection.create_connection(   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\connection.py", line 84, in create_connection
    raise err   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\connection.py", line 74, in create_connection
    sock.connect(sa) socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 994, in _validate_conn
    conn.connect()   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 300, in connect
    conn = self._new_conn()   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 161, in _new_conn
    raise ConnectTimeoutError( urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.VerifiedHTTPSConnection object at 0x04587B80>, 'Connection to api.telegram.org timed out. (connect timeout=3.5)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 719, in urlopen
    retries = retries.increment(   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /botТОКЕН/sendMessage?chat_id=482347840&text=%D0%A5%D0%BE%D1%80%D0%BE%D1%88%D0%BE%2C+%D0%B2%D1%8B%D0%B1%D0%B8%D1%80%D0%B0%D0%B9+%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D1%83&reply_markup=%7B%22keyboard%22%3A+%5B%5B%7B%22text%22%3A+%22Discord%22%7D%2C+%7B%22text%22%3A+%22Telegram%22%7D%2C+%7B%22text%22%3A+%22MediaGet%22%7D%5D%2C+%5B%7B%22text%22%3A+%22FPSMonitor%22%7D%2C+%7B%22text%22%3A+%22AIDA64%22%7D%2C+%7B%22text%22%3A+%22PyCharm%22%7D%5D%2C+%5B%7B%22text%22%3A+%22Skype%22%7D%2C+%7B%22text%22%3A+%22Chrome%22%7D%2C+%7B%22text%22%3A+%22Steam%22%7D%5D%2C+%5B%7B%22text%22%3A+%22%5Cu043c%5Cu0435%5Cu043d%5Cu044e%22%7D%5D%5D%7D (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x04587B80>, 'Connection to api.telegram.org timed out. (connect timeout=3.5)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 60, in run
    task(*args, **kwargs)   File "C:\Users\tegram.py", line 57, in actions
    bot.send_message(message.chat.id, 'Хорошо, выбирай программу', reply_markup=klawa21)   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 600, in send_message
    apihelper.send_message(self.token, chat_id, text, disable_web_page_preview, reply_to_message_id,   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 154, in send_message
    return _make_request(token, method_url, params=payload, method='post')   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 57, in _make_request
    result = _get_req_session().request(method, request_url, params=params, files=files,   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 504, in send
    raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /botТОКЕН/sendMessage?chat_id=482347840&text=%D0%A5%D0%BE%D1%80%D0%BE%D1%88%D0%BE%2C+%D0%B2%D1%8B%D0%B1%D0%B8%D1%80%D0%B0%D0%B9+%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D1%83&reply_markup=%7B%22keyboard%22%3A+%5B%5B%7B%22text%22%3A+%22Discord%22%7D%2C+%7B%22text%22%3A+%22Telegram%22%7D%2C+%7B%22text%22%3A+%22MediaGet%22%7D%5D%2C+%5B%7B%22text%22%3A+%22FPSMonitor%22%7D%2C+%7B%22text%22%3A+%22AIDA64%22%7D%2C+%7B%22text%22%3A+%22PyCharm%22%7D%5D%2C+%5B%7B%22text%22%3A+%22Skype%22%7D%2C+%7B%22text%22%3A+%22Chrome%22%7D%2C+%7B%22text%22%3A+%22Steam%22%7D%5D%2C+%5B%7B%22text%22%3A+%22%5Cu043c%5Cu0435%5Cu043d%5Cu044e%22%7D%5D%5D%7D (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x04587B80>, 'Connection to api.telegram.org timed out. (connect timeout=3.5)')) " Traceback (most recent call last):   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 156, in _new_conn
    conn = connection.create_connection(   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\connection.py", line 84, in create_connection
    raise err   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\connection.py", line 74, in create_connection
    sock.connect(sa) socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 994, in _validate_conn
    conn.connect()   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 300, in connect
    conn = self._new_conn()   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 161, in _new_conn
    raise ConnectTimeoutError( urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.VerifiedHTTPSConnection object at 0x04587B80>, 'Connection to api.telegram.org timed out. (connect timeout=3.5)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 719, in urlopen
    retries = retries.increment(   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /botТОКЕН/sendMessage?chat_id=482347840&text=%D0%A5%D0%BE%D1%80%D0%BE%D1%88%D0%BE%2C+%D0%B2%D1%8B%D0%B1%D0%B8%D1%80%D0%B0%D0%B9+%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D1%83&reply_markup=%7B%22keyboard%22%3A+%5B%5B%7B%22text%22%3A+%22Discord%22%7D%2C+%7B%22text%22%3A+%22Telegram%22%7D%2C+%7B%22text%22%3A+%22MediaGet%22%7D%5D%2C+%5B%7B%22text%22%3A+%22FPSMonitor%22%7D%2C+%7B%22text%22%3A+%22AIDA64%22%7D%2C+%7B%22text%22%3A+%22PyCharm%22%7D%5D%2C+%5B%7B%22text%22%3A+%22Skype%22%7D%2C+%7B%22text%22%3A+%22Chrome%22%7D%2C+%7B%22text%22%3A+%22Steam%22%7D%5D%2C+%5B%7B%22text%22%3A+%22%5Cu043c%5Cu0435%5Cu043d%5Cu044e%22%7D%5D%5D%7D (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x04587B80>, 'Connection to api.telegram.org timed out. (connect timeout=3.5)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File "C:\Users\tegram.py", line 115, in <module>
    bot.polling()   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 392, in polling
    self.__threaded_polling(none_stop, interval, timeout)   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 416, in __threaded_polling
    self.worker_pool.raise_exceptions()   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 109, in raise_exceptions
    six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2])   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\six.py", line 703, in reraise
    raise value   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\util.py", line 60, in run
    task(*args, **kwargs)   File "C:\Users\tegram.py", line 57, in actions
    bot.send_message(message.chat.id, 'Хорошо, выбирай программу', reply_markup=klawa21)   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\__init__.py", line 600, in send_message
    apihelper.send_message(self.token, chat_id, text, disable_web_page_preview, reply_to_message_id,   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 154, in send_message
    return _make_request(token, method_url, params=payload, method='post')   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\telebot\apihelper.py", line 57, in _make_request
    result = _get_req_session().request(method, request_url, params=params, files=files,   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)   File "C:\Users\илья\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 504, in send
    raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /botТОКЕН/sendMessage?chat_id=482347840&text=%D0%A5%D0%BE%D1%80%D0%BE%D1%88%D0%BE%2C+%D0%B2%D1%8B%D0%B1%D0%B8%D1%80%D0%B0%D0%B9+%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D1%83&reply_markup=%7B%22keyboard%22%3A+%5B%5B%7B%22text%22%3A+%22Discord%22%7D%2C+%7B%22text%22%3A+%22Telegram%22%7D%2C+%7B%22text%22%3A+%22MediaGet%22%7D%5D%2C+%5B%7B%22text%22%3A+%22FPSMonitor%22%7D%2C+%7B%22text%22%3A+%22AIDA64%22%7D%2C+%7B%22text%22%3A+%22PyCharm%22%7D%5D%2C+%5B%7B%22text%22%3A+%22Skype%22%7D%2C+%7B%22text%22%3A+%22Chrome%22%7D%2C+%7B%22text%22%3A+%22Steam%22%7D%5D%2C+%5B%7B%22text%22%3A+%22%5Cu043c%5Cu0435%5Cu043d%5Cu044e%22%7D%5D%5D%7D (Caused by ConnectTimeoutError(<urllib3.connection.VerifiedHTTPSConnection object at 0x04587B80>, 'Connection to api.telegram.org timed out. (connect timeout=3.5)'))

вот код моего бота

import telebot
import requests
import os

bot = telebot.TeleBot('токен бота')
# команды пример: /start
@bot.message_handler(commands=['start'])
def launch_bot(message):
    bot.send_message(message.chat.id, 'Привет, что дальше?', reply_markup=klawa)
# клавиатура меню
klawa = telebot.types.ReplyKeyboardMarkup()
klawa.row('игра', 'управление', 'программы',)
klawa.row(' ','сайт ', ' ')
# клавиатура игры
klawa2 = telebot.types.ReplyKeyboardMarkup()
klawa2.row('PUBG LITE', 'Overwatch', 'Tomb Raider')
klawa2.row('меню', ' ', 'дальше')
klawa3 = telebot.types.ReplyKeyboardMarkup()
klawa3.row('Watch Dogs 2', 'Witcher 3', 'NFS')
klawa3.row('меню', 'назад', ' ')
# клавиатура управление
klawa4 = telebot.types.ReplyKeyboardMarkup()
klawa4.row('быстрые настройки', 'user настройки', 'admin настройки')
klawa4.row('меню', 'обратно', 'вперед')

# перключение между клавиатурами
@bot.message_handler(content_types=['text'])
def actions(message):
    if message.text == 'меню':
        bot.send_message(message.chat.id, 'Хорошо, идем в меню', reply_markup=klawa)
    elif message.text == 'дальше':
        bot.send_message(message.chat.id, 'Хорошо, смотрим следующий список', reply_markup=klawa3)
    elif message.text == 'назад':
        bot.send_message(message.chat.id, 'Ладно, посмотрим предыдущий список', reply_markup=klawa2)
    elif message.text == 'обратно':
        bot.send_message(message.chat.id, 'Ладно, посмотрим предыдущий список', reply_markup=klawa4)
# ответы бота и его действия
# действия первой клавиатуры меню klawa
    elif message.text == 'игра':
        bot.send_message(message.chat.id, 'во что сыграем?', reply_markup=klawa2)
    elif message.text == 'управление':
        bot.send_message(message.chat.id, 'Что сделать?', reply_markup=klawa4)
    elif message.text == 'программы':
        bot.send_message(message.chat.id, 'хорошо, как лучше сделать?')
    elif message.text == 'сайт':
        bot.send_message(message.chat.id, 'Что за сайт?')
# действия клавиатуры игра klawa2, klawa3
    elif message.text == 'PUBG LITE':
        bot.send_message(message.chat.id, 'Хорошо, запускаю PUBG LITE')
        os.system(r'C:\"Program Files (x86)"\PUBGLite\Launcher.exe')
    elif message.text == 'Overwatch':
        bot.send_message(message.chat.id, 'Хорошо, запускаю Overwatch')
        os.system(r'C:\"Program Files (x86)"\Overwatch\"Overwatch Launcher.exe"')
    elif message.text == 'Tomb Raider':
        bot.send_message(message.chat.id, 'Хорошо, запускаю Tomb Raider')
        os.system(r'C:\Games\"Rise of the Tomb Raider"\ROTTR.exe')
    elif message.text == 'Watch Dogs 2':
        bot.send_message(message.chat.id, 'Хорошо, запускаю Watch Dogs 2')
        os.system(r'C:\Games\"Watch Dogs 2"\bin\"WatchDogs2.exe"')
    elif message.text == 'Witcher 3':
        bot.send_message(message.chat.id, 'Хорошо, запускаю Witcher 3')
        os.system(r'C:\Games\"The Witcher 3 Wild Hunt GOTY"\"Witcher 3.exe"')
    elif message.text == 'NFS':
        bot.send_message(message.chat.id, 'Хорошо, запускаю NFS')
        os.system(r'C:\Games\"Need for Speed Payback"\"Need for Speed Payback.exe"')
# действия клавиатуры управление klawa4
bot.polling()

Ответы (0 шт):