UnicodeEncodeError: 'charmap' codec can't encode character ...

Issue #62 invalid
Tyler Durden created an issue

OS = windows 10 running python 3.5.2

Getting this bug which crashes webdl

C:\webdl>venv\Scripts\activate.bat

(venv) C:\webdl>python grabber.py
  1) ABC iView
  2) Nine
  3) SBS
  4) Ten
  0) Back
Choose> 4
  1) Art Without Borders
  2) Australia By Design
  3) Australian Fishing Championships Series XIII
  4) Australian Survivor
  5) The Bachelor Australia
  6) The Bachelorette Australia
  7) Becoming Bold and Beautiful
  8) The Biggest Loser: Transformed
  9) Bob's Burgers
 10) The Bold and The Beautiful
 11) Bull
 12) The Caravan
 13) Common Sense
 14) Crocamole
 15) Cruise Mode
 16) Daryl Beattie Adventures
 17) Documentaries
 18) Driven Not Hidden
 19) Escape Fishing With ET
 20) Everyday Gourmet With Justine Schofield
 21) Family Feud
 22) Fishing Edge
 23) Fresh Off The Boat
 24) Gillette World Sport
 25) The Graham Norton Show
 26) Hamish Macdonald's The Truth Is?
 27) Have You Been Paying Attention?
 28) Hillsong
 29) Hour Of Power With Bobby Schuller
 30) iFish
 31) IFS Championship
 32) It Is Written
 33) Joel Osteen
 34) Joseph Prince: New Creation Church
 35) Joyce Meyer: Enjoying Everyday Life
 36) Kuu Kuu Harajuku
 37) The Last Man On Earth
 38) The Late Late Show with James Corden
 39) The Late Show With Stephen Colbert
 40) Lexi and Lottie: Trusty Twin Detectives
 41) Life In Pieces
 42) The Living Room
 43) The Living Room 1
 44) The Living Room Summer Series
 45) Mass For You At Home
 46) MasterChef Australia
 47) MasterChef Australia: Class Of 2014
 48) Megastructures
 49) Megastructures Breakdown
 50) Mia And Me
 51) Micronation
 52) Miguel's Feasts
 53) Monster Jam
 54) Mothers Who Murder
 55) Movies
 56) My Market Kitchen
 57) NCIS
 58) NCIS: New Orleans
 59) Neighbours
 60) Neighbours Summer Stories
 61) New Girl
 62) Offspring
 63) Operation Repo
 64) Places We Love: An Earth Hour Special
 65) Pooches At Play
 66) The Project
 67) The Project Long Form
 68) Random And Whacky
 69) Reef Doctors
 70) Reel Action
 71) Ripper Street
 72) RPM
 73) RPM GP
 74) RPM: Summer Series
 75) Scope
 76) Scorpion
 77) Shark Tank
 78) St Francis
 79) Studio 10
 80) TEN Eyewitness News First At Five
 81) Todd Sampson's Body Hack
Traceback (most recent call last):
  File "grabber.py", line 55, in <module>
    main()
  File "grabber.py", line 40, in main
    result = choose(options, allow_multi=will_download)
  File "grabber.py", line 9, in choose
    print("%3d) %s" % (i+1, key))
  File "C:\webdl\venv\lib\encodings\cp850.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2019' in position 17: character maps to <undefined>

Comments (6)

  1. delx repo owner

    Hi @madmax3,

    Thanks for creating a new issue. You're right that this looks similar to issue #5, however they have different causes.

    Issue #5 was obsolete once I dropped support for running with Python 2. The fix you noticed had a syntax error, but it will not do the right thing with Python 3 because Unicode is handled differently.

    I think the problem is your terminal encoding is not set to utf-8. You can check this by running the following command:

    python -c 'import sys; print(sys.stdout.encoding)'
    

    If you're using the Linux then assuming your terminal actually supports UTF-8 you can set the LANG environment variable to fix this:

    LANG=en_AU.utf-8 python -c 'import sys; print(sys.stdout.encoding)'
    

    On Windows I'm not sure how to do this. If you're using the Windows/Linux subsystem then the same approach may work.

    Python has some documentation on this here. I guess you want to set the PYTHONIOENCODING variable instead.

  2. Log in to comment