How to add PyTZ to Google App Engine app?

This is a bit confusing, but I could not find good resources on this topic.

I am working on a Google App Engine application that requires complex conversions in the time zone. Since I’m nowhere close to the quotas entered, I decided to go with PyTZ. However, I have to do something wrong. What i have done so far:

  • Loaded PyTZ as tarball
  • Installed and copied the pytz directory to the root of my application (it is the brother of the webapp directory where it is located app.yaml).

However, if I try to create time intervals, PyTZ seems to never find. Here is an example session from the GAE interactive console:

from pytz import timezone

rome = timezone('Europe/Rome')

The conclusion is as follows:

Traceback (most recent call last):
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/admin/__init__.py", line 210, in post
    exec(compiled_code, globals())
  File "<string>", line 3, in <module>
  File "/Library/Python/2.5/site-packages/pytz-2009j-py2.5.egg/pytz/__init__.py", line 157, in timezone
UnknownTimeZoneError: 'Europe/Rome'

What am I doing wrong? Thank you in advance for your help.

. python, :

>>> from pytz import datetime, timezone
>>> rome = timezone('Europe/Rome')
>>> rome.localize(datetime.datetime.now())
datetime.datetime(2009, 11, 12, 0, 4, 52, 990114, tzinfo=<DstTzInfo 'Europe/Rome' CET+1:00:00 STD>)

: , zip- PyTZ. zoneinfo :

pc-morena:pytz lyudmilangelov$ cd zoneinfo/
pc-morena:zoneinfo lyudmilangelov$ ls -l
total 448
drwxr-xr-x@  55 lyudmilangelov  staff   1870 Nov 10 12:48 Africa
drwxr-xr-x@ 135 lyudmilangelov  staff   4590 Nov 10 12:48 America
drwxr-xr-x@  12 lyudmilangelov  staff    408 Nov 10 12:48 Antarctica
drwxr-xr-x@   3 lyudmilangelov  staff    102 Nov 10 12:48 Arctic
drwxr-xr-x@  93 lyudmilangelov  staff   3162 Nov 10 12:48 Asia
...
+3
6

, ( ), jgeewax answer, , , . , github, pytz zipped zoneinfo . - 30 , : http://github.com/mpstx/appengine_py_pytz_zipimport_zoneinfo

+4

gae-pytz, pytz-appengine. , pytz-appengine ndb.

pytz ( , ). pytz-appengine , . script build.py, .

.

+4

, zoneinfo pytz - 570 22 , pytz, . , - , , . appcfg.py -verbose update ( --noisy) , ,

, open_resource init.py, " " zip , "". blog , ( ).

+3

, , .

, ( ) PyTZ a sibling webapp. , GAE , webapp. , , import pytz , .

, PyTZ webapp , - webapp (, test).

+2

gae-pytz, : http://pypi.python.org/pypi/gaepytz

pytz , gae , :

from pytz.gae import pytz
+2

Source: https://habr.com/ru/post/1722629/


All Articles