Skip to content

Error when creating an instance of Gazetteer #9

Description

@jamesabrook

Using the provided example code (below) I get an error when it tries to create an instance of Gazetteer.

Code:

from gazetteer import Gazetteer  # import the library

gz = Gazetteer()  # gazetteer instance
coordinates = [
    (-74.0060, 40.7128),
    (76.2673, 9.9312),
]  # list of tuples, in order longitude,latitude
for data in gz.search(coordinates):  # gz.search() returns a generator
    print(data)  # GeocoderResultBaseModel

Error:

Exception has occurred: UnicodeDecodeError
'charmap' codec can't decode byte 0x90 in position 1475: character maps to

Traceback:

File "d:\Projects\geoguessr\src_exploration\test_gazetteer.py", line 3, in
gz = Gazetteer() # gazetteer instance
File "C:\Users\james\AppData\Local\Programs\Python\Python314\Lib\site-packages\gazetteer\reverse_geocode.py", line 65, in getinstance
instances[cls] = cls(**kwargs)
~~~^^^^^^^^^^
File "C:\Users\james\AppData\Local\Programs\Python\Python314\Lib\site-packages\gazetteer\reverse_geocode.py", line 85, in init
coordinates, self.locations = self._load()
~~~~~~~~~~^^
File "C:\Users\james\AppData\Local\Programs\Python\Python314\Lib\site-packages\gazetteer\reverse_geocode.py", line 103, in _load
header = stream_reader.fieldnames
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\james\AppData\Local\Programs\Python\Python314\Lib\csv.py", line 163, in fieldnames
self._fieldnames = next(self.reader)
~~~~^^^^^^^^^^^^^
File "C:\Users\james\AppData\Local\Programs\Python\Python314\Lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 1475: character maps to

I've just installed a fresh copy of python 3.14.2 and Gazetteer using pip install python-gazetteer as per the readme. I'm running on Windows 11 using VSCode.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions