访问网站时,报错信息如下
timezone = get_current_timezone()
File "/root/anaconda3/envs/myenv_py3.9/lib/python3.9/site-packages/django/utils/timdezone.py", line 74, in get_current_timezone
return getattr(_active, "value", get_default_timezone())
File "/root/anaconda3/envs/myenv_py3.9/lib/python3.9/site-packages/django/utils/timezone.py", line 60, in get_default_timezone
return zoneinfo.ZoneInfo(settings.TIME_ZONE)
File "/root/anaconda3/envs/myenv_py3.9/lib/python3.9/zoneinfo/_common.py", line 24, in load_tzdata
raise ZoneInfoNotFoundError(f"No time zone found with key {key}")
zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key Asia/Shanghai'
打开文件/root/anaconda3/envs/myenv_py3.9/lib/python3.9/zoneinfo/_common.py", 备注提示可能的原因
查看tzdata的安装包,没有在python3.9/site-packages/里看到
conda list查看安装包,发现已经有tzdata
就把别的服务器上存在的tzdata包拷贝到离线服务器上,问题解决。