Python Forum
Encoding Error? Good in IDLE not in ATOM - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Encoding Error? Good in IDLE not in ATOM (/thread-3232.html)



Encoding Error? Good in IDLE not in ATOM - vetabz - May-07-2017

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>



RE: Encoding Error? Good in IDLE not in ATOM - snippsat - May-08-2017

(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'))



RE: Encoding Error? Good in IDLE not in ATOM - vetabz - May-09-2017

I posted this problem in Atom discussions here:

https://discuss.atom.io/t/encoding-error-atom-specific/42496/8


RE: Encoding Error? Good in IDLE not in ATOM - Larz60+ - May-10-2017

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.