pyhon2.7没有时区模块pytz,如果要使用时区相关的函数,需要安装pytz,网上有很多easy_install的方法,本文采用最新的pip安装方法。
pip vs easy_install¶可以查看https://packaging.python.org/discussions/pip-vs-easy-install/#pip-vs-easy-install
easy_install was released in 2004, as part of setuptools. It was notable at the time for installing packages from PyPI using requirement specifiers, and automatically installing dependencies.
pip came later in 2008, as alternative to easy_install, although still largely built on top of setuptools components. It was notable at the time for not installing packages as Eggs or from Eggs (but rather simply as ‘flat’ packages from sdists), and introducing the idea of Requirements Files, which gave users the power to easily replicate environments.
好了,直接上安装pytz,
1、先安装PIP
On Linux or OS X:
pip install -U pip setuptools
On Windows:
python -m pip install -U pip setuptools
2、安装pytz模块
python -m pip install pytz
3、安装截图如下
4、具体安装过程可参考官方文档:
https://packaging.python.org/tutorials/installing-packages/