gpt4 book ai didi

python - 远程机器人 : AttributeError: 'NoneType' object has no attribute 'format'

转载 作者:太空宇宙 更新时间:2023-11-03 20:03:46 34 4
gpt4 key购买 nike

大家好!我正在使用 pyTelegramBotApi 编写 Telegram 机器人。这是我的代码:

import telebot
from telebot import apihelper
bot = telebot.TeleBot(TOKEN);
apihelper.proxy = {'https': 'socks5://154.221.21.197:10800'}
bot.polling()

当我尝试运行它时,出现错误:

2019-11-28 00:44:10,836 (util.py:66 PollingThread) ERROR - TeleBot: "AttributeError occurred, args=("'NoneType' object has no attribute 'format'",)
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\util.py", line 60, in run
task(*args, **kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 278, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 248, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\apihelper.py", line 189, in get_updates
return _make_request(token, method_url, params=payload)
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\apihelper.py", line 49, in _make_request
request_url = base_url.format(token, method_name)
AttributeError: 'NoneType' object has no attribute 'format'
"
Traceback (most recent call last):
File "C:/Users/user/PycharmProjects/bot/newbot.py", line 14, in <module>
bot.polling()
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 391, in polling
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 414, in __threaded_polling
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\util.py", line 79, in raise_exceptions
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\six-1.13.0-py3.7.egg\six.py", line 696, in reraise
raise value
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\util.py", line 60, in run
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 278, in __retrieve_updates
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\__init__.py", line 248, in get_updates
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\apihelper.py", line 189, in get_updates
File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytelegrambotapi-3.6.6-py3.7.egg\telebot\apihelper.py", line 49, in _make_request
AttributeError: 'NoneType' object has no attribute 'format'

Process finished with exit code 1

这是什么问题以及如何解决这个问题?代理正在工作(尝试与应用程序连接),gunicorn、PySocks、pyTelegramBotAPI、requests、urllib3 最新版本已安装。

  • IDE:PyCharm 3.0.3
  • Python 3.7.4

谢谢!

最佳答案

打开

...\Python3x\Lib\site-packages\pyTelegramBotAPI-3.6.6-py3.8.egg\telebot\apihelper.py

找到#49行并对其进行注释。它可能不正确,但它有效

http://prntscr.com/q43pne

关于python - 远程机器人 : AttributeError: 'NoneType' object has no attribute 'format' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59083300/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com