I have a clean VPS, with Ubuntu 14.04 LTS x64. And Tried the following:

# Upgrade The Base Packages

apt-get update
apt-get upgrade -y

# Add A Few PPAs To Stay Current

apt-get install -y software-properties-common

apt-add-repository ppa:nginx/stable -y
apt-add-repository ppa:rwky/redis -y
apt-add-repository ppa:chris-lea/node.js -y
apt-add-repository ppa:ondrej/php5-5.6 -y

But then it fails at the last one:

root@xxx:~# apt-add-repository ppa:ondrej/php5-5.6 -y

gpg: keyring `/tmp/tmp9jdzm9kw/secring.gpg' created
gpg: keyring `/tmp/tmp9jdzm9kw/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp9jdzm9kw/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ond\xc5\x99ej Sur�" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 687, in addkey_func
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 370, in add_key
    return apsk.add_ppa_signing_key()
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 261, in add_ppa_signing_key
    tmp_export_keyring, signing_key_fingerprint, tmp_keyring_dir):
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 210, in _verify_fingerprint
    got_fingerprints = self._get_fingerprints(keyring, keyring_dir)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 202, in _get_fingerprints
    output = subprocess.check_output(cmd, universal_newlines=True)
  File "/usr/lib/python3.4/subprocess.py", line 605, in check_output
    output, unused_err = process.communicate(inputdata, timeout=timeout)
  File "/usr/lib/python3.4/subprocess.py", line 936, in communicate
    stdout = _eintr_retry_call(self.stdout.read)
  File "/usr/lib/python3.4/subprocess.py", line 487, in _eintr_retry_call
    return func(*args)
  File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 92: ordinal not in range(128)

I couldn't figure out whats wrong. It's all pretty basic.

  • 1
    Just got that error when building Docker image, try chaining adding repository with export LANG=C.UTF-8, it worked for me. Apr 13, 2015 at 17:10
  • @TomaszKowalczyk that worked for me as well, thanks! Aug 23, 2015 at 19:46

4 Answers 4


The proper way is to enable UTF-8 support in your terminal.

First check your locales:

locale -a

Then, install an UTF-8 locale, for en_US, the example as follows:

locale-gen en_US.UTF-8

Then you need to export it:

export LANG=en_US.UTF-8

Then the add-apt-repository command will work okay.

If this still doesn't still work, try using this line:

LC_ALL=en_US.UTF-8 add-apt-repository -y ppa:ondrej/php

  • Thank you so much for your help. This was the only way I got it working. But why does Linux makes things so complicated? Can't there be a standard that must be followed so all work smoothly? I am not saying Windows is great as I am ditching it for Linux, but my god there is always something not working or throwing errors. It is so frustrating. Whatever my mood, I want to thank you for this perfect process.
    – marcnz
    Dec 1, 2015 at 4:25
  • You're welcome! Some distributions (especially customised server editions by VPS providers) are cooked as minimal, and do not include UTF-8 support packages for less space, resources as far as I can tell.
    – Arda
    Dec 1, 2015 at 9:50
  • Hm... It doesn't work Cannot add PPA: 'ppa:ondrej/php5-5.6'. Please check that the PPA name or format is correct.
    – Kirby
    Dec 23, 2016 at 14:40
  • @Kirby It's because PPA name is changed. I've updated my answer accordingly. The one ppa ondrej/php now holds all PHP versions maintained by its author.
    – Arda
    Dec 23, 2016 at 15:33

I faced the same problem. I think the error comes because of the non western characters in the name (Ond\xc5\x99ej Sur�).

Make sure you removed php5.

You can add the repository manually:

# echo "deb http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu trusty main" > /etc/apt/sources.list.d/ondrej-php5-5_6-trusty.list

# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C

# apt-get install php5

Check with php -v whether you have 5.6 installed:

# php -v
PHP 5.6.6-1+deb.sury.org~trusty+1 (cli) (built: Feb 20 2015 11:22:10) 

Try installing a language pack which may correct your issues with encoding, e.g.

sudo apt-get install language-pack-en

This will provide English translation data updates for all supported packages (including Python).

See: UnicodeEncodeError: 'ascii' codec can't encode character.


Try the following:

  • Please remove if you already installed php5.

  • Now try to a fresh installation.

  • Run gedit /etc/apt/sources.list to add following codes:

    deb http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu trusty main 
    deb-src http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu trusty main

    Please careful to edit and add source code.

  • Save and update it. (1234)

    sudo apt-get update  
  • Now try to install php5.

After installed you should get php5-5.6.

  • Tried that. Didn't work. It was a fresh install, without php on it by the way.
    – fiibaar
    Feb 11, 2015 at 13:07
  • You need the ppa keys imported for this to work.
    – Arda
    Nov 14, 2015 at 10:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .