Python Error "SyntaxError: Non-ASCII character '\xe2' in file C:/path/ on line 3, but no encoding declared"

0 votes

I'm trying to execute a code and I get the following error

SyntaxError: Non-ASCII character '\xe2' in file C:/path/ on line 3, but no encoding declared
import pandas as pd

df = pd.read_csv(“C:\Users\Kamal\Desktop\Desktop\datasets\ex.xls”)

for index, row in df.iterrows():
    print (row['email'])
Jun 13, 2019 in Python by Kamal
3,935 views

1 answer to this question.

0 votes

add the following line on top of your python code:

# -*- coding: utf-8 -*-

Also, avoid using non-ascii quotations.

answered Jun 13, 2019 by Rhea

Related Questions In Python

0 votes
1 answer

Enter a 1-10, each on a new line in a file - python

Try something like this: i=1 for i in range(10): ...READ MORE

answered Jun 20, 2019 in Python by Greg
52 views
0 votes
0 answers

I am trying to install PyBase64 on my python 3.8. But I end up with the following error:

$ pip install pybase ERROR: Could not find ...READ MORE

Mar 24 in Python by Nishant
• 210 points
217 views
0 votes
0 answers

I am trying to install os-win on my python 3.8. But I end up with the following error:

ERROR: Command errored out with exit status ...READ MORE

Mar 24 in Python by Nishant
• 210 points
379 views
0 votes
1 answer

I am trying to install visualize on my python 3.8 but i end up with the followinf error.

Hi@Avinash, I think the module name is visualization ...READ MORE

answered Apr 27 in Python by MD
• 31,430 points
62 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,049 views
0 votes
0 answers
+4 votes
6 answers
0 votes
2 answers

Python Error "UnicodeEncodeError: 'ascii' codec can't encode character u'\u03b1' in position 20: ordinal not in range(128)"

import csv import sys reload(sys) sys.setdefaultencoding('utf8') data = [["a", "b", u'\xe9']] with ...READ MORE

answered Jun 28, 2019 in Python by anonymous
3,555 views
0 votes
2 answers

In Python, how do I read a file line-by-line into a list?

readline function help to  read line in ...READ MORE

answered Jun 21 in Python by sahil
• 500 points
225 views