[Tutor] Installing modules with easy_install

Joel Goldstick joel.goldstick at gmail.com
Tue Aug 28 19:48:46 CEST 2012


On Tue, Aug 28, 2012 at 1:41 PM, Ray Jones <crawlzone at gmail.com> wrote:
> I'm working on another Python replacement for a Bash script, and I ran
> into a need for enhanced time zone functions. Following directions I
> found on a web site, I did the following:
>
> # easy_install --upgrade pytz
> Searching for pytz
> Reading http://pypi.python.org/simple/pytz/
> Reading http://pytz.sourceforge.net
> Reading http://sourceforge.net/project/showfiles.php?group_id=79122
> Reading http://www.stuartbishop.net/Software/pytz
> Reading http://sourceforge.net/projects/pytz/
> Best match: pytz 2012d
> Downloading
> http://pypi.python.org/packages/2.7/p/pytz/pytz-2012d-py2.7.egg#md5=e6f9219ae6eff242f13c6700413df69e
> Processing pytz-2012d-py2.7.egg
> creating /usr/local/lib/python2.7/dist-packages/pytz-2012d-py2.7.egg
> Extracting pytz-2012d-py2.7.egg to /usr/local/lib/python2.7/dist-packages
> Adding pytz 2012d to easy-install.pth file
>
> Installed /usr/local/lib/python2.7/dist-packages/pytz-2012d-py2.7.egg
> Processing dependencies for pytz
> Finished processing dependencies for pytz
>
>
> Everything I'm reading suggests that now I should have the pytz module
> available to me. But from iPython:
>
>
> In [1]: import pytz
> ---------------------------------------------------------------------------
> ImportError                               Traceback (most recent call last)
>
> /home/ray/<ipython console> in <module>()
>
> ImportError: No module named pytz
>
>
> In [2]: import pytz-2012d
> ------------------------------------------------------------
>    File "<ipython console>", line 1
>      import pytz-2012d
>                 ^
> SyntaxError: invalid syntax
>
>
>
> So what do I need to do to get Python to recognize this module?
>
>
> Ray
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

so you are calling it the wrong thing when you import


see here: http://pytz.sourceforge.net/#example-usage
Example & Usage
Localized times and date arithmetic

>>> from datetime import datetime, timedelta
>>> from pytz import timezone
>>> import pytz
>>> utc = pytz.utc
>>> utc.zone
'UTC'
>>> eastern = timezone('US/Eastern')
>>> eastern.zone
'US/Eastern'
>>> amsterdam = timezone('Europe/Amsterdam')
>>> fmt = '%Y-%m-%d %H:%M:%S %Z%z'




-- 
Joel Goldstick


More information about the Tutor mailing list