asweigart / pyperclip

Python module for cross-platform clipboard functions.
https://pypi.python.org/pypi/pyperclip
BSD 3-Clause "New" or "Revised" License
1.67k stars 196 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte … invalid start byte #113

Open karlstartswithk opened 6 years ago

karlstartswithk commented 6 years ago

I am currently working through Automate the Boring Stuff with Python: Practical Programming for Total Beginners and I have come across a bug I can't seem to get a good answer for.

The error is:

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyperclip/__init__.py", line 596, in lazy_load_stub_paste     
    return paste()   
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pyperclip/__init__.py", line 109, in paste_osx_pbcopy     
    return stdout.decode(ENCODING) 
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa8 in position 197: invalid start byte

The problematic line of code:

text = str(pyperclip.paste())

The only way I could get the full script to work was by decreasing with is copied from the webpage. Instead of using CTRL+A then CTRL+C, I manually selected only the text portion of the main body on the page.

I tried a few suggestions from Stack Overflow, but the did not seem to work.

https://stackoverflow.com/questions/47735949/unicodedecodeerror-utf-8-codec-cant-decode-byte-invalid-start-byte

dickgroenenberg commented 4 years ago

Encoding issue; remove the registered trademark symbol (next to LEGO)