Search code examples
pythonpytz

Python pytz: timezone("xxx") gives "unpack requires a string argument of length 44"


I am getting an error "struct.error: unpack requires a string argument of length 44" when I try to create some of the timezones using pytz. For others it works fine.

The first two work great. The second two give the error:

import pytz
from pytz import timezone

tz_dk = timezone("Europe/Copenhagen") 
tz_cn =  timezone("Atlantic/Canary")

tz_us = timezone("US/Eastern")
tx_lo = timezone("Europe/London")

I printed out a list of all the time zones and all four are there.

for tz in pytz.all_timezones:
    print tz

Solution

  • I reinstalled pytz and now it works. Weird.

    Tested it with

    for value in pytz.all_timezones:
         try:
            t =  timezone(value)
        except:
            print "FAIL", value
    

    No fails.