I'm working on a Python 3.7.9 program (.py) that works perfectly fine when running on both CMD terminal and PyCharm (I am using the reverse_geocoder module - it is relevant to the error). I then used pyinstaller to convert the .py file to .exe. I got the file in the dist folder. But, when running it I get an error:
(I have imported reverse_geocoder as rg -since that pops up in the error)
Traceback (most recent call last):
File "myProgram.py", line 235, in <module>
location = reverseGeocode(coordinates)
File "myProgram.py", line 170, in reverseGeocode
result = rg.search(coordinates)
File "reverse_geocoder\__init__.py", line 292, in search
File "reverse_geocoder\__init__.py", line 88, in getinstance
File "reverse_geocoder\__init__.py", line 111, in __init__
File "reverse_geocoder\__init__.py", line 197, in extract
File "c:\users\USER\appdata\local\programs\python\python37\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 286: character maps to <undefined>
I tried adding encoding='utf-8' to open() in reverse_geocoder_init_.py as suggested by several forum questions, but the error didn't change. Can somebody help me out? P.S. I'm a beginner in Python so please simplify the answers if possible.
I couldn't solve this. Instead, I decided to use the Bing Reverse geocoder and it solved my issue. That was a lot easier, with smaller code block, and more free API calls per month.