Python Forum
Encoding Error? Good in IDLE not in ATOM
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Encoding Error? Good in IDLE not in ATOM
#1
I'm trying to follow SentDex tutorial on youtube but I'm getting this error(see below) on ATOM but not in IDLE

I checked my ATOM settings and encoding was set to UTF8 so I'm not sure what going on now.

The code is:
import bs4 as bs
import urllib.request as ur


sauce = ur.urlopen('https://pythonprogramming.net/parsememcparseface/').read()
soup = bs.BeautifulSoup(sauce, 'lxml')
print(soup.find_all('p'))
The error I got from ATOM
Error:
Traceback (most recent call last):  File "C:\Programming\Codes\Py\BS4_Tut_1.py", line 7, in <module>    print(soup.find_all('p'))  File "C:\Programming\Python36\lib\encodings\cp1252.py", line 19, in encode    return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u1d90' in position 602: character maps to <undefined>
Reply
#2
(May-07-2017, 03:11 PM)vetabz Wrote: I checked my ATOM settings and encoding was set to UTF8 so I'm not sure what going on now.
My advice is that you run from command line,use a better cmd like cmder.
My setup is Atom with cmder(GitHub), do also as linked here.
The runner from inside Atom can give errors,when printing a lot of stuff.

You should also use Requests(get correct encoding from web-site) not urllib.
import requests
from bs4 import BeautifulSoup

url = 'https://pythonprogramming.net/parsememcparseface/'
url_get = requests.get(url)
soup = BeautifulSoup(url_get.content, 'lxml')
print(soup.find_all('p'))
Reply
#3
I posted this problem in Atom discussions here:

https://discuss.atom.io/t/encoding-error...ic/42496/8
Reply
#4
Be careful when you say it's working fine in idle.
Idle is known for doing some strange stuff (although you may have gotten lucky).
Snippsat's advice looks sound, and cmder is an excellent console emulator.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  BeautifulSoup Installed but not Found in Atom wakegate 4 5,110 Jun-14-2019, 05:54 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020