2016-02-03 51 views
1

導入UTC我試圖運行包含以下行的舊腳本:無法從的iCalendar

from icalendar import UTC 

這給了我以下錯誤:

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: cannot import name UTC 

所以我檢查了變化日誌icalendar其規定如下:

Renamed the UTC class to Utc , so it would not clash with the UTC object, since that rendered the UTC object unpicklable.

我改變UTCUtc,仍然會得到相同的錯誤。

我該如何擺脫這個錯誤?

回答

1

https://pypi.python.org/pypi/icalendar時區支持部分,它指出:

Instead of our own UTC tzinfo implementation we use pytz UTC tzinfo object now.

因此,我要建議你使用:

from pytz import UTC 

...而不是:

from icalendar import UTC