add-apt-repository引发Python错误:UnicodeDecodeError:'ascii'编解码器无法解码字节0xc5


27

尝试安装最新的PHP5软件包,所以我添加了repo(sudo add-apt-repository ppa:ondrej / php5),这是结果:

    Traceback (most recent call last):
  File "/usr/lib/python3.2/threading.py", line 740, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 141, in run
    self.add_ppa_signing_key(self.ppa_path)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 234, in add_ppa_signing_key
    tmp_export_keyring, signing_key_fingerprint, tmp_keyring_dir):
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 186, in _verify_fingerprint
    got_fingerprints = self._get_fingerprints(keyring, keyring_dir)
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 178, in _get_fingerprints
    output = subprocess.check_output(cmd, universal_newlines=True)
  File "/usr/lib/python3.2/subprocess.py", line 516, in check_output
    output, unused_err = process.communicate()
  File "/usr/lib/python3.2/subprocess.py", line 811, in communicate
    stdout = _eintr_retry_call(self.stdout.read)
  File "/usr/lib/python3.2/subprocess.py", line 456, in _eintr_retry_call
    return func(*args)
  File "/usr/lib/python3.2/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)

在Ubuntu 12.04 Server上运行


1
您是否迷惑了默认的python安装(例如,将python3.2符号链接到/ usr / bin / python?)-apt应该在12.04上使用系统默认的python2.7。您可以将的输出添加ls -l $(which python)到您的帖子中吗?
steeldriver

lrwxrwxrwx 1 root root 2013年4月9日/ usr / bin / python-> python2.7我确实安装了软件包以获取apt-add-repo(与Python iiirc混在一起)
James Heald

在那种情况下,我不明白为什么它显然使用python3.2-抱歉
steeldriver 2014年

Answers:


66

常见的software-properties是bug,因此,如果有时间,请将其报告为software-properties-common中的错误。

问题跟踪器中指出了一个更好的解决方法,该跟踪器在添加存储库时使用特定的Unicode语言环境

LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php5-5.6


2

如果您在docker中,这对我有用:

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

之后:

RUN apt-get update
RUN apt-get install -y php7.2

0

对我来说,在php解决ubuntu 16上的问题之前添加php5-compat。

sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php5-compat

然后

sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.