UnicodeDecodeError in python2
See original GitHub issuegoogleimagesdownload -k ‘สวัสดีครับ’ -l 5
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/bin/googleimagesdownload", line 10, in <module>
sys.exit(main())
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google_images_download/google_images_download.py", line 998, in main
paths,errors = response.download(arguments) #wrapping response in a variable just for consistency
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google_images_download/google_images_download.py", line 825, in download
paths, errors = self.download_executor(arguments)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google_images_download/google_images_download.py", line 922, in download_executor
print(iteration.encode('raw_unicode_escape').decode('utf-8'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 29: ordinal not in range(128)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:6
Top Results From Across the Web
UnicodeDecodeError - Python Wiki
The UnicodeDecodeError normally happens when decoding an str string from a certain coding. Since codings map only a limited number of str ...
Read more >UnicodeDecodeError: 'ascii' codec can't decode byte
The Python "UnicodeDecodeError: 'ascii' codec can't decode byte in position" occurs when we use the ascii codec to decode bytes that were ...
Read more >Solving Unicode Problems in Python 2.7 - Azavea
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 1: ordinal not in range(128) (Why is this so hard??)
Read more >Overcoming frustration: Correctly using unicode in python2
In python, the unicode type stores an abstract sequence of code points. ... up with an exception being raised (UnicodeDecodeError or UnicodeEncodeError).
Read more >UnicodeDecodeError on Python2 #2003 - pypa/setuptools
I'm trying to install wheel on Python 2 and getting an UnicodeDecodeError caused by a non-ASCII filename in the test tree of the...
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 FreeTop 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
Top GitHub Comments
Same issue in python3.7.
A workaround is to replace non-ascii characters by their unicode representation.
Python 3:
Python 2:
Replace
if not isinstance(string, bytes):
byif not isinstance(string, unicode):
It’s a bug while trying to print the exactly name in the utf-8 encoding. if you were using python3, you can just git clone the project and remove the decode in
google_images_download/google_images_download.py
like this:print(iteration.encode('raw_unicode_escape').decode('utf-8'))
into
print(iteration.encode('raw_unicode_escape'))
then uninstall the origin one andpython setup.py install
the modified one. Althought it print bad on screen but it works fine. Using python2 will have another problem… ps. still dont know why the example in website using Chinese that pass but another language decode have problem …