UnicodeEncodeError when geocoding result contains non-ASCII character
See original GitHub issueWhen trying to encode an address whose result would contain a non-ASCII character (e.g. é, á, ž etc.), I get this error. Using iPython 2.7 in Anaconda on Windows 7. Any ideas? Thanks for the great library BTW!
In [58]: s = geocoder.bing("Champs de Mars, Paris", proxies=proxies)
In [59]: s
Out[59]: <[OK] Bing - Geocode [Champ de Mars, Paris, France]>
In [60]: s = geocoder.bing("Avenue Champs Elysees, Paris", proxies=proxies)
---------------------------------------------------------------------------
UnicodeEncodeError Traceback (most recent call last)
<ipython-input-60-62b4e3a20efb> in <module>()
----> 1 s = geocoder.bing("Avenue Champs Elysees, Paris", proxies=proxies)
C:\Documents\SW\Anaconda\lib\site-packages\geocoder\api.pyc in bing(location, **kwargs)
205 > reverse
206 """
--> 207 return get(location, provider='bing', **kwargs)
208
209
C:\Documents\SW\Anaconda\lib\site-packages\geocoder\api.pyc in get(location, **kwargs)
101 '>>> g = geocoder.get([45.68, -75.15], method="reverse
")')
102 sys.exit()
--> 103 return options[provider][method](location, **kwargs)
104
105
C:\Documents\SW\Anaconda\lib\site-packages\geocoder\bing.pyc in __init__(self, location, **kwargs)
65 'maxResults': 1,
66 }
---> 67 self._initialize(**kwargs)
68 self._bing_catch_errors()
69
C:\Documents\SW\Anaconda\lib\site-packages\geocoder\base.pyc in _initialize(self, **kwargs)
99 self._build_tree(self.content)
100 self._exceptions()
--> 101 self._json()
102
103 def _json(self):
C:\Documents\SW\Anaconda\lib\site-packages\geocoder\base.pyc in _json(self)
105 if bool(not key.startswith('_') and key not in self._exclude
):
106 self.fieldnames.append(key)
--> 107 value = getattr(self, key)
108 if value:
109 self.json[key] = value
C:\Documents\SW\Anaconda\lib\site-packages\geocoder\bing.pyc in housenumber(self)
105 expression = r'\d+'
106 pattern = re.compile(expression)
--> 107 match = pattern.search(str(self.street))
108 if match:
109 return match.group(0)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xc9' in position 18:
ordinal not in range(128)
Issue Analytics
- State:
- Created 9 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Geocoding address involving non-ASCII characters in ...
The problem is that the returned address contains non-ASCII characters. Any ideas to solve this? from geopy.geocoders import Nominatim #Next, we ...
Read more >Confusion with unicode in Python
First, check if addressString is a Unicode object (it is if you're using Python 3, or if type(addressString) shows 'unicode').
Read more >Changelog of the 0.9 series — GeoPy 2.3.0 documentation
CHANGED: Geocoders' geocode and reverse method return types have changed from None, a tuple, or a list of tuples, to None, a geopy.Location ......
Read more >Stata Module for Forward and Reserve Geocoding
variables to be in Unicode (UTF-8). That is address names may contain accented characters, symbols and non-latin characters. For older releases, the input ......
Read more >CSV, TXT, and GPX files—Portal for ArcGIS
For example, address and ZIP Code will yield better results than just address. ... If you import an ASCII-encoded file containing non-English characters, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m getting this issue with:
Update: Issue seems to be with the loc.address property:
It is good to hear you are interested in fixing it. =) I also made a manual correction in base.py line 62 to fix an encoding problem there: