xubin2021 2021-12-13 01:02 采纳率: 0%
浏览 142

我的定时发微信消息的程序出错tzlocal.utils.ZoneInfoNotFoundError: ''报错怎么解决,

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
from datetime import datetime
import itchat
import xlrd
from apscheduler.schedulers.background import BlockingScheduler





def SentChatRoomsMsg(name, context):
    itchat.get_chatrooms(update=True)
    iRoom = itchat.search_chatrooms(name)
    for room in iRoom:
        if room['NickName'] == name:
            userName = room['UserName']
            break
    itchat.send_msg(context, userName)
    print("发送时间:" + datetime.now().strftime("%Y-%m-%d %H:%M:%S") + "\n"
                                                                   "发送到:" + name + "\n"
                                                                                   "发送内容:" + context + "\n")
    print("*********************************************************************************")
    scheduler.print_jobs()


def loginCallback():
    print("***登录成功***")


def exitCallback():
    print("***已退出***")

#产生二维码
itchat.auto_login()
#定义用户的昵称
send_userid='微信昵称'
#查找用户的userid
itcaht_user_name = itchat.search_friends(name=send_userid)[0]['UserName']
#利用send_msg发送消息
itchat.send_msg('Robin的微信已经登录',toUserName=itcaht_user_name)



workbook = xlrd.open_workbook("chatroomsfile\AutoSentChatroom.xls")
# workbook = xlrd.open_workbook("D:\PyCharmCode\AutoLiulishouWechat\chatroomsfile\AutoSentChatroom.xlsx")
sheet = workbook.sheet_by_name('Chatrooms')
iRows = sheet.nrows

scheduler = BlockingScheduler()
index = 1
for i in range(1, iRows):
    textList = sheet.row_values(i)
    name = textList[0]
    context = textList[2]
    float_dateTime = textList[1]
    date_value = xlrd.xldate_as_tuple(float_dateTime, workbook.datemode)
    date_value = datetime(*date_value[:5])
    if datetime.now() > date_value:
        continue
    date_value = date_value.strftime('%Y-%m-%d %H:%M:%S')
    textList[1] = date_value
    scheduler.add_job(SentChatRoomsMsg, 'date', run_date=date_value,
                      kwargs={"name": name, "context": context})
    print("任务" + str(index) + ":\n"
                              "待发送时间:" + date_value + "\n"
                                                      "待发送到:" + name + "\n"
                                                                       "待发送内容:" + context + "\n"
                                                                                            "******************************************************************************\n")
    index = index + 1

if index == 1:
    print("***没有任务需要执行***")
scheduler.start()




运行结果及报错内容

Traceback (most recent call last):
File "D:/002-python all/定时发微信信息/main.py", line 49, in
scheduler = BlockingScheduler()
File "C:\Users\xubintai\anaconda3\lib\site-packages\apscheduler\schedulers\base.py", line 87, in init
self.configure(gconfig, **options)
File "C:\Users\xubintai\anaconda3\lib\site-packages\apscheduler\schedulers\base.py", line 131, in configure
self._configure(config)
File "C:\Users\xubintai\anaconda3\lib\site-packages\apscheduler\schedulers\base.py", line 702, in _configure
self.timezone = astimezone(config.pop('timezone', None)) or get_localzone()
File "C:\Users\xubintai\anaconda3\lib\site-packages\tzlocal\win32.py", line 119, in get_localzone
_cache_tz = pds.timezone(get_localzone_name())
File "C:\Users\xubintai\anaconda3\lib\site-packages\tzlocal\win32.py", line 109, in get_localzone_name
_cache_tz_name = _get_localzone_name()
File "C:\Users\xubintai\anaconda3\lib\site-packages\tzlocal\win32.py", line 77, in _get_localzone_name
raise utils.ZoneInfoNotFoundError(tzkeyname)
tzlocal.utils.ZoneInfoNotFoundError: ''

Process finished with exit code 1

我的解答思路和尝试过的方法

无法修正

PS D:\002-python all\定时发微信信息> timezone

Id : China Standard Time
DisplayName : (UTC+08:00) 北京,重庆,香港特别行政区,乌鲁木齐
StandardName : 中国标准时间
DaylightName : 中国夏令时
BaseUtcOffset : 08:00:00
SupportsDaylightSavingTime : False

我想要达到的结果.

tzlocal.utils.ZoneInfoNotFoundError: ''.
怎么解决啊?
多谢。

  • 写回答

1条回答 默认 最新

  • CSDN专家-黄老师 2021-12-13 09:29
    关注

    itchat已经不再维护了,微信也更新了导致itchat无法使用了。现在只能用自动化操作实现机器人功能

    评论

报告相同问题?

问题事件

  • 创建了问题 12月13日

悬赏问题

  • ¥15 悬赏Python-playwright部署在centos7上
  • ¥15 psoc creator软件有没有人能远程安装啊
  • ¥15 快速扫描算法求解Eikonal方程咨询
  • ¥20 我的是道格手机,重置后屏幕右上角出现红色字的未写入tee key 和未写入google key请问怎么去掉啊
  • ¥30 关于R语言运行分区生存模型中的问题!
  • ¥15 校内二手商品转让网站
  • ¥20 高德地图聚合图层MarkerCluster聚合多个点,但是ClusterData只有其中部分数据,原因应该是有经纬度重合的地方点,现在我想让ClusterData显示所有点的信息,如何实现?
  • ¥100 求Web版SPC控制图程序包调式
  • ¥20 指导如何跑通以下两个Github代码
  • ¥15 大家知道这个后备文件怎么删吗,为啥这些文件我只看到一份,没有后备呀