Re: Convert Latitude, Longitude To TimeZone

Discussion in 'Python' started by Roy Smith, Mar 31, 2013.

  1. Roy Smith

    Roy Smith Guest

    In article <>,
    Steve B <> wrote:

    > I found a piece of code
    > [http://blog.pamelafox.org/2012/04/converting-addresses-to-timezones-in.html
    > ] which uses the function [https://gist.github.com/pamelafox/2288222]
    >
    > When I try to run the code, I get the error geonames is not defined (This is
    > the function previously linked to)


    The best thing to do when asking questions like this is to copy-paste
    the exact error message you got. It was probably something like:

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    NameError: name 'geonames' is not defined

    In this example, it's easy enough to figure out what went wrong from
    your description, but in general, giving the exact error helps in the
    diagnosis.

    > geonames_client = geonames.GeonamesClient('Username_alpha')
    >
    > geonames_result = geonames_client.find_timezone({'lat': 48.871236, 'lng':
    > 2.77928})
    >
    > user.timezone = geonames_result['timezoneId']


    You simply never imported the geonames module. Somewhere before your
    first line of code, you want to add:

    import geonames

    This assumes that you've saved the module in a file named "geonames.py".
     
    Roy Smith, Mar 31, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. YS Sze
    Replies:
    4
    Views:
    646
    -berlin.de
    Feb 7, 2004
  2. kbperry
    Replies:
    2
    Views:
    313
    kbperry
    May 31, 2006
  3. Replies:
    5
    Views:
    2,572
    Luc The Perverse
    Aug 14, 2006
  4. Replies:
    1
    Views:
    545
    Roedy Green
    Aug 13, 2012
  5. clusardi2k
    Replies:
    1
    Views:
    634
    Roedy Green
    Aug 13, 2012
Loading...

Share This Page