question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[python36] UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 27: ordinal not in range(128)

See original GitHub issue

@StevenBlack Weird PYTHON 3.6 ISSUE:

[fademind@manjaro .uhf]$ python updateHostsFile.py -a --replace --flush-dns-cache                                  
Updating source data/add.Spam from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Spam/hosts   
Updating source data/UncheckyAds from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/UncheckyAds/hosts
Updating source data/SpotifyAds from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/SpotifyAds/hosts
Updating source data/mvps.org from http://winhelp2002.mvps.org/hosts.txt
Updating source data/add.Risk from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Risk/hosts
Updating source data/StevenBlack from https://raw.githubusercontent.com/StevenBlack/hosts/master/data/StevenBlack/hosts
Updating source data/malwaredomainlist.com from https://www.malwaredomainlist.com/hostslist/hosts.txt
Updating source data/hpHosts.partial from https://hosts-file.net/hphosts-partial.txt
Updating source data/add.2o7Net from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.2o7Net/hosts
Updating source data/KADhosts from https://raw.githubusercontent.com/azet12/KADhosts/master/KADhosts.txt
Updating source data/add.Dead from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Dead/hosts
Updating source data/Badd-Boyz-Hosts from https://raw.githubusercontent.com/mitchellkrogza/Badd-Boyz-Hosts/master/hosts
Updating source data/adaway.org from https://raw.githubusercontent.com/AdAway/adaway.github.io/master/hosts.txt
Updating source data/WindowsSpyBlocker/spy-win10 from https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/win10/spy.txt
Updating source data/WindowsSpyBlocker/spy-win81 from https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/win81/spy.txt
Updating source data/tyzbit from https://raw.githubusercontent.com/tyzbit/hosts/master/data/tyzbit/hosts
Traceback (most recent call last):
  File "updateHostsFile.py", line 582, in <module>
    main()
  File "updateHostsFile.py", line 142, in main
    promptForUpdate()
  File "updateHostsFile.py", line 174, in promptForUpdate
    updateAllSources()
  File "updateHostsFile.py", line 255, in updateAllSources
    updateData = json.load(updateFile)
  File "/usr/lib/python3.6/json/__init__.py", line 296, in load
    return loads(fp.read(),
  File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 27: ordinal not in range(128)

Running script in PYTHON2 LEGACY went fine:

[fademind@manjaro .uhf]$ python2 updateHostsFile.py -a --replace --flush-dns-cache
Updating source ./data/add.Spam from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Spam/hosts
Updating source ./data/UncheckyAds from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/UncheckyAds/hosts
Updating source ./data/SpotifyAds from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/SpotifyAds/hosts
Updating source ./data/mvps.org from http://winhelp2002.mvps.org/hosts.txt
Updating source ./data/add.Risk from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Risk/hosts
Updating source ./data/StevenBlack from https://raw.githubusercontent.com/StevenBlack/hosts/master/data/StevenBlack/hosts
Updating source ./data/malwaredomainlist.com from https://www.malwaredomainlist.com/hostslist/hosts.txt
Updating source ./data/hpHosts.partial from https://hosts-file.net/hphosts-partial.txt
Updating source ./data/add.2o7Net from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.2o7Net/hosts
Updating source ./data/KADhosts from https://raw.githubusercontent.com/azet12/KADhosts/master/KADhosts.txt
Updating source ./data/add.Dead from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Dead/hosts
Updating source ./data/Badd-Boyz-Hosts from https://raw.githubusercontent.com/mitchellkrogza/Badd-Boyz-Hosts/master/hosts
Updating source ./data/adaway.org from https://raw.githubusercontent.com/AdAway/adaway.github.io/master/hosts.txt
Updating source ./data/WindowsSpyBlocker/spy-win10 from https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/win10/spy.txt
Updating source ./data/WindowsSpyBlocker/spy-win81 from https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/win81/spy.txt
Updating source ./data/tyzbit from https://raw.githubusercontent.com/tyzbit/hosts/master/data/tyzbit/hosts
Updating source ./data/someonewhocares.org from http://someonewhocares.org/hosts/zero/hosts
Updating source ./data/yoyo.org from https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext&useip=0.0.0.0
Updating source ./data/hpHosts from https://hosts-file.net/download/hosts.txt
Updating source ./hosts-master/data/add.Spam from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Spam/hosts
Updating source ./hosts-master/data/UncheckyAds from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/UncheckyAds/hosts
Updating source ./hosts-master/data/SpotifyAds from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/SpotifyAds/hosts
Updating source ./hosts-master/data/mvps.org from http://winhelp2002.mvps.org/hosts.txt
Updating source ./hosts-master/data/add.Risk from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Risk/hosts
Updating source ./hosts-master/data/StevenBlack from https://raw.githubusercontent.com/StevenBlack/hosts/master/data/StevenBlack/hosts
Updating source ./hosts-master/data/malwaredomainlist.com from https://www.malwaredomainlist.com/hostslist/hosts.txt
Updating source ./hosts-master/data/add.2o7Net from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.2o7Net/hosts
Updating source ./hosts-master/data/KADhosts from https://raw.githubusercontent.com/azet12/KADhosts/master/KADhosts.txt
Updating source ./hosts-master/data/add.Dead from https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Dead/hosts
Updating source ./hosts-master/data/Badd-Boyz-Hosts from https://raw.githubusercontent.com/mitchellkrogza/Badd-Boyz-Hosts/master/hosts
Updating source ./hosts-master/data/adaway.org from https://raw.githubusercontent.com/AdAway/adaway.github.io/master/hosts.txt
Updating source ./hosts-master/data/tyzbit from https://raw.githubusercontent.com/tyzbit/hosts/master/data/tyzbit/hosts
Updating source ./hosts-master/data/someonewhocares.org from http://someonewhocares.org/hosts/zero/hosts
Updating source ./hosts-master/data/yoyo.org from https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext&useip=0.0.0.0
Updating source ./hosts-master/extensions/gambling from https://raw.githubusercontent.com/Sinfonietta/hostfiles/master/gambling-hosts
Updating source ./hosts-master/extensions/porn/clefspeare13 from https://raw.githubusercontent.com/Clefspeare13/pornhosts/master/0.0.0.0/hosts
Updating source ./hosts-master/extensions/porn/sinfonietta from https://raw.githubusercontent.com/Sinfonietta/hostfiles/master/pornography-hosts
Updating source ./hosts-master/extensions/social from https://raw.githubusercontent.com/Sinfonietta/hostfiles/master/social-hosts
Updating source ./hosts-master/extensions/fakenews from https://raw.githubusercontent.com/marktron/fakenews/master/fakenews
Updating source ./extensions/gambling from https://raw.githubusercontent.com/Sinfonietta/hostfiles/master/gambling-hosts
Updating source ./extensions/porn/clefspeare13 from https://raw.githubusercontent.com/Clefspeare13/pornhosts/master/0.0.0.0/hosts
Updating source ./extensions/porn/sinfonietta from https://raw.githubusercontent.com/Sinfonietta/hostfiles/master/pornography-hosts
Updating source ./extensions/social from https://raw.githubusercontent.com/Sinfonietta/hostfiles/master/social-hosts
Updating source ./extensions/fakenews from https://raw.githubusercontent.com/marktron/fakenews/master/fakenews
Success! The hosts file has been saved in folder 
It contains 626,665 unique entries.
Moving the file requires administrative privileges. You might need to enter your password.
Flushing the DNS cache to utilize new hosts file...
Flushing the DNS cache requires administrative privileges. You might need to enter your password.
Flushing DNS by restarting NetworkManager succeeded
Flushing DNS by restarting dnsmasq succeeded

ENVIRONMENT

Manjaro Linux x86_64

[fademind@manjaro ~]$ pacman -Q|grep python
python 3.6.0-2
python-appdirs 1.4.2-1
python-beaker 1.8.1-2
python-cairo 1.10.0-8
python-chardet 2.3.0-4
python-dbus 1.2.4-2
python-dbus-common 1.2.4-2
python-docopt 0.6.2-4
python-gobject 3.22.0-2
python-jinja 2.9.5-1
python-keyutils 0.4-1
python-mako 1.0.6-2
python-markdown 2.6.8-1
python-markupsafe 0.23-4
python-npyscreen 4.10.5-1
python-olefile 0.43-2
python-packaging 16.8-2
python-pillow 4.0.0-2
python-pip 9.0.1-2
python-pycups 1.9.73-3
python-pycurl 7.43.0-2
python-pygments 2.2.0-1
python-pyparsing 2.1.10-2
python-pyqt4 4.12-4
python-pyqt5 5.8-1
python-pysmbc 1.0.15.6-2
python-reportlab 3.3.0-2
python-requests 2.13.0-1
python-setuptools 1:34.3.1-1
python-sip 4.19.1-1
python-six 1.10.0-3
python-urllib3 1.20-1
python-xdg 0.25-4
python-yaml 3.12-2
python2 2.7.13-1
python2-appdirs 1.4.2-1
python2-beaker 1.8.1-2
python2-cairo 1.10.0-2
python2-gobject2 2.28.6-13
python2-m2crypto 0.24.0-1
python2-mako 1.0.6-2
python2-markupsafe 0.23-4
python2-olefile 0.43-2
python2-packaging 16.8-2
python2-pillow 4.0.0-2
python2-pybluez 0.22-2
python2-pyparsing 2.1.10-2
python2-setuptools 1:34.3.1-1
python2-simplejson 3.10.0-2
python2-six 1.10.0-3
[fademind@manjaro ~]$ 

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
FadeMindcommented, May 25, 2017

It was my hard drive issue. SSD freak out.

0reactions
gfyoungcommented, May 24, 2017

@FadeMind : Is this still an issue for you?

Read more comments on GitHub >

github_iconTop Results From Across the Web

'ascii' codec can't decode byte 0xe2 in position 13: ordinal not ...
The file is being read as a bunch of str s, but it should be unicode s. Python tries to implicitly convert, but...
Read more >
'ascii' codec can't decode byte 0xe2 in position 5599 ... - GitHub
UnicodeDecodeError : 'ascii' codec can't decode byte 0xe2 in position 5599: ordinal not in range(128) #87.
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 >
'ascii' codec can't decode byte 0xe2 in position 13: ordinal not ...
PYTHON : UnicodeDecodeError : ' ascii ' codec can't decode byte 0xe2 in position 13: ordinal not in range ( 128 ) [...
Read more >
陆三斤的博客-CSDN博客_ascii' codec can't decode byte 0xe2
遇到过多次编码错误,最常遇到的就是下面这个: “UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)“ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found