简体   繁体   中英

Python - Why is reverse geocode throwing a UnicodeDecode error?

I'm following the instructions at this link .

The code is as follows:

import reverse_geocode
coordinates = (-37.81, 144.96), (31.76, 35.21)
reverse_geocode.search(coordinates)

Instead of the output shown at the link, I get the following error:

UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 464: character maps to <undefined>

Note that it isn't an import problem; I could import the module fine with Python3.

What's going wrong?

This looks to be an issue with reverse_geocode . This issue has been fixed in the source code as of July, but this fix has yet to make its way into a release.

Until then, the workaround is to modify Lib\\site-packages\\reverse_geocode\\__init__.py under wherever you have Python installed. Edit this file and add the argument encoding="utf-8" to all calls to open() .

修改 Lib\\site-packages\\reverse_geocode_ init _.py 并编辑 open(,encoding="utf-8")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM