I am getting the following error when I run the code below when running my python code in Cloud9 IDE using the default version of Python (2.7.6):
import urllib
artistValue = "Sigur Rós"
artistValueUrl = urllib.quote(artistValue)
SyntaxError: Non-ASCII character '\xc3' in file /home/ubuntu/workspace/test.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
I read to adjust to the following code below was a work around.
import urllib
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
artistValue = "Sigur Rós"
artistValueUrl = urllib.quote(artistValue)
When I tried this a red x pop-up error that read:
Module 'sys' has no 'setdefaultencoding' member"
and if I run the code I still get the Syntax Error.
Why is this happening and what should I do?
EDIT: I also tried the following from the selected answer:
import urllib
print urllib.quote(u"Sigur Rós")
When I ran it I received the following error:
SyntaxError: Non-ASCII character '\xc3' in file /home/ubuntu/workspace/test.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details