Ask Your Question

UTF-8 error in macOS version WingIDE

asked 2017-10-03 04:19:00 -0600

andrewd76's avatar

updated 2019-03-13 10:12:53 -0600

Hi,I'm trying to read this utf-8 file in this Python script:

import csv

with open(csv_filename) as csv_fd:
    reader = csv.reader(csv_fd, delimiter=';')
    for row in reader:

But get an error in WingIDE (macOS):

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/", line 26, in decode return
builtins.UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 227: ordinal not in range(128)

There are "Unicode UTF-8" in "Preferences - Debugger - I/O" ("Encoding" fields).

If I run this script in Terminal there is no such kind of error.There is no error if I run this script in Windows version of WingIDE.


edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2017-10-03 07:51:00 -0600

Chris Curvey's avatar

updated 2019-03-07 07:44:41 -0600

Wingware Admin's avatar

This has something to do with the default encoding that is set in your environments (which explains why it might work when run via other methods)

hmm, looks like you're using Python 3 (at least through Wing).  I'd bet that

with open(csv_filename, encoding='utf-8') as csv_fd:

would work (assuming the file is encoded as utf-8)

edit flag offensive delete link more


I think this is correct and best to always be explicit about encodings to avoid things like this.  One thing to note is that the Debugger > I/O Encoding is used only for locally launched processes.  If you're debugging on a remote host then the remote host configuration sets the I/O encoding instead under its Options tab.  This is because the correct encoding to use by default varies by OS.

Wingware Support's avatar Wingware Support  ( 2017-10-03 09:18:00 -0600 )edit

answered 2017-10-03 12:24:00 -0600

andrewd76's avatar

Thank you so much! It works

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2017-10-03 04:19:00 -0600

Seen: 1,946 times

Last updated: Mar 07 '19