How to Install pytz/dateutil python modules



  • Sorry I'm a bit lost with FreeBSD, I can do this with Windows or Linux, but I need a bit of help with FreeBSD/pfSense.

    I'm doing some custom scripting, and I need to be able to convert from local time (both my local time, and anther server that is in another time zone)to gmt.  Unfortunately datetime.strptime "%z" doesn't work, so it looks like I need to resort to either pytz or dateutil module which isn't part of the standard library.

    Is there an easy way to install modules?  Should I install pip?  (Is this easy to do?/How?)

    Best way to deal with system updates if I do?

    I would like to make the least change possible to the system.

    Thanks.



  • python2.7 -m ensurepip



  • @RonpfS:

    python2.7 -m ensurepip

    Thanks…

    For the benefit of the other noobs:

    python2.7 -m ensurepip

    • installs pip

    python2.7 -m pip install pytz

    • installs module pytz

    Follow up questions:

    When I ran the install I got the following mesages:
    Successfully installed pytz-2016.6.1
    You are using pip version 8.1.1, however version 8.1.2 is available.
    You should consider upgrading via the 'pip install –upgrade pip' command.

    Should I upgrade pip as suggested, or is this likely to cause trouble?

    Will these changes survive an upgrade, or do they need to be reapplied?

    Thanks.



  • I just updated  ::)



  • pkg install py27-dateutil
    or
    pkg install py27-pytz

    This won't work for all python modules, but there are a number of pre-packaged ones including these.