reverse_geocode icon indicating copy to clipboard operation
reverse_geocode copied to clipboard

'charmap' codec error

Open MrX310 opened this issue 4 years ago • 2 comments

We have installed the tool for python 3.9 on a Windows 10 pc and tested it with the example, but it don't work. See error message below:

raceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Users\huete\PycharmProjects\BigData\venv\lib\site-packages\reverse_geocode\__init__.py", line 121, in search
    gd = GeocodeData()
  File "C:\Users\huete\PycharmProjects\BigData\venv\lib\site-packages\reverse_geocode\__init__.py", line 25, in getinstance
    instances[cls] = cls()
  File "C:\Users\huete\PycharmProjects\BigData\venv\lib\site-packages\reverse_geocode\__init__.py", line 34, in __init__
    coordinates, self.locations = self.extract(rel_path(geocode_filename))
  File "C:\Users\huete\PycharmProjects\BigData\venv\lib\site-packages\reverse_geocode\__init__.py", line 100, in extract
    for latitude, longitude, country_code, city in rows:
  File "C:\Users\huete\AppData\Local\Programs\Python\Python39\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 0x81 in position 464: character maps to <undefined>

MrX310 avatar Jan 19 '21 14:01 MrX310

The problem seems to be with csv.reader. Manually adding the encoding parameter to init.py seems to solve the problem. For example: rows = csv.reader(open(local_filename, encoding='utf-8'))

OlegSidibou avatar Jan 22 '21 14:01 OlegSidibou

I added PR https://github.com/richardpenman/reverse_geocode/pull/10 to fix it.

blushingpenguin avatar Jan 28 '21 16:01 blushingpenguin

This encoding parameter is now added.

richardpenman avatar Jun 07 '24 11:06 richardpenman