Timezone Information Missing in pytz?

后端 未结 8 1549
轻奢々
轻奢々 2020-12-31 16:17

I\'m having a very weird problem with Python\'s pytz: it seems to have an incomplete catalog of timezones on my system (MacOS X 10.8.5, system Python 2.7.5).

相关标签:
8条回答
  • 2020-12-31 17:04

    I cannot say why your installation of pytz is broken, but here's a possible fix:

    1. Download the .zip archive of pytz from the Python Package Index.
    2. In Terminal.app, run pip show pytz.
    3. Using the path it returns, run open /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (replacing my path with yours if different). This will launch a Finder window with your Python modules.
    4. Find the pytz/ folder. Open it.
    5. Replace the zoneinfo/ folder with the zoneinfo/ folder that's in the .zip archive you downloaded in step 1 from PyPI.
    0 讨论(0)
  • 2020-12-31 17:04

    I had a similar exception UnknownTimeZoneError: Can not find any timezone configuration when i tried to run my app inside a docker container with the latest ubuntu images. It turned out that tzdata was missing. Installing tzdata package fixed it:

    apt-get install -y tzdata
    
    # Maybe you will need to reconfigure the timezone as well:
    ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime
    dpkg-reconfigure -f noninteractive tzdata
    

    (Use sudo if you have to)

    0 讨论(0)
提交回复
热议问题