Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've written this python script to list all the display_name's from a team members in Launchpad:

from launchpadlib.launchpad import Launchpad
cachedir = "/home/username/.launchpadlib/cache/"
launchpad = Launchpad.login_anonymously('just testing', 'production', cachedir)
team = launchpad.people['']
for person in team.members:
   print person.display_name


But when I execute the script piping it into an output file, it fails when finding a non-ascii name:

    $ python > /tmp/file
Traceback (most recent call last):
  File "", line 7, in <module>
    print person.display_name
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 8: ordinal not in range(128)

Any ideas?

share|improve this question
up vote 2 down vote accepted


  print person.display_name.encode('utf-8')

to tell Python what character encoding to use for unicode strings.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.