问题描述
我试图在我的web应用程序中使用pytz将时区应用于日期时间对象。首先,我尝试导入pytz像这样
I'm trying to use pytz in my web app to apply a timezone to a datetime object. First I tried importing pytz like this
from pytz import timezone
然后它引发一个ImportError,说模块pytz不存在。我在IDLE中尝试了相同的代码行,它工作正常。然后我在网上看到关于gae-pytz的信息。所以
我改变了我的代码看起来像这样:
Then it raised an ImportError saying that the module "pytz" didn't exist. I tried the same line of code in IDLE and it worked fine. Then I saw something online about gae-pytz. SoI changed my code to look like this:
from pytz.gae import pytz
from pytz import timezone
就像网页所说的那样。它仍然有ImportError。它说:
Just like the webpage said. It still has the ImportError. It says:
ImportError: No module named pytz.gae
我认为这个问题可能是因为我使用python 2.5的gae版本。
有人知道什么是错的?或者也许有人知道pytz的替代品。
I think the problem may be that I'm using the gae version for python 2.5.Anybody know what's wrong? Or maybe somebody knows an alternative to pytz.
推荐答案
我使用gae-pytz,效果很好。看起来你可能有路径问题。 pytz是否在您的应用程序引擎项目的根目录中?这是它应该的地方。
I use gae-pytz and it works great. Looks like you might have a path problem. Is the pytz dir in the root of your app engine project? That is where it should be.
这篇关于ImportError,在谷歌应用程序引擎中使用pytz的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!