add-apt-repository出Exception问题

本文解决了一个在使用sudo add-apt-repository命令添加PPA源时出现的UnicodeDecodeError错误问题,该问题是由于代理设置不当引起的。文章提供了详细的解决步骤,包括使用gpg命令手动添加PGP密钥。

参考:http://blog.sina.com.cn/s/blog_5388923c0100nu8h.html

症状:

xxxx@xxxxx:~$ sudo add-apt-repository ppa:nikount/orta-desktop
Exception in thread Thread-1:
Traceback (most recent call last):
    File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner
       self.run()
    File "/usr/lib/python2.6/dist-packages/softwareproperties/ppa.py", line 63, in run
       self.add_ppa_signing_key(self.ppa_path)
    File "/usr/lib/python2.6/dist-packages/softwareproperties/ppa.py", line 92, in add_ppa_signing_key
       print "Error reading %s: %s" % (lp_url, e)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 27: ordinal not in range(128)

解决:

说是代理问题,如果在局域网上网的同志估计没招了,虽然出这个提示,但是实际源已经添加了,但是PGP没有添加,所以再用pgp指令添加pgp即可:

gpg --keyserver subkeys.pgp.net --recv 6E871C4A881574DE
gpg --export --armor 6E871C4A881574DE | sudo apt-key add -


malibugirl3@OS-20250816XBYN:/mnt/c/Users/Administrator$ sudo add-apt-repository universe Traceback (most recent call last): File "/usr/bin/add-apt-repository", line 108, in <module> sp = SoftwareProperties(options=options) File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 112, in __init__ self.sourceslist = SourcesList() File "/usr/lib/python3/dist-packages/aptsources/sourceslist.py", line 273, in __init__ self.matcher = SourceEntryMatcher(matcherPath) File "/usr/lib/python3/dist-packages/aptsources/sourceslist.py", line 474, in __init__ dist = DistInfo(f, base_dir=matcherPath) File "/usr/lib/python3/dist-packages/aptsources/distinfo.py", line 188, in __init__ tokens = line.split(&#39;:&#39;, 1) TypeError: &#39;str&#39; object is not callable Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 66, in apport_excepthook from cStringIO import StringIO File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 971, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 914, in _find_spec File "<frozen importlib._bootstrap_external>", line 1407, in find_spec File "<frozen importlib._bootstrap_external>", line 1379, in _get_spec File "<frozen importlib._bootstrap_external>", line 1537, in find_spec File "<frozen importlib._bootstrap>", line 224, in _verbose_message TypeError: &#39;>=&#39; not supported between instances of &#39;int&#39; and &#39;str&#39; Original exception was: Traceback (most recent call last): File "/usr/bin/add-apt-repository", line 108, in <module> sp = SoftwareProperties(options=options) File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 112, in __init__ self.sourceslist = SourcesList() File "/usr/lib/python3/dist-packages/aptsources/sourceslist.py", line 273, in __init__ self.matcher = SourceEntryMatcher(matcherPath) File "/usr/lib/python3/dist-packages/aptsources/sourceslist.py", line 474, in __init__ dist = DistInfo(f, base_dir=matcherPath) File "/usr/lib/python3/dist-packages/aptsources/distinfo.py", line 188, in __init__ tokens = line.split(&#39;:&#39;, 1) TypeError: &#39;str&#39; object is not callable
最新发布
11-23
huaxi@ubuntu:~/repo$ sudo add-apt-repository --remove ppa:deadsnakes/ppa This PPA contains more recent Python versions packaged for Ubuntu. Disclaimer: there&#39;s no guarantee of timely updates in case of security problems or other issues. If you want to use them in a security-or-otherwise-critical environment (say, on a production server), you do so at your own risk. Update Note =========== Please use this repository instead of ppa:fkrull/deadsnakes. Reporting Issues ================ Issues can be reported in the master issue tracker at: https://github.com/deadsnakes/issues/issues Supported Ubuntu and Python Versions ==================================== - Ubuntu 20.04 (focal) Python3.5 - Python3.7, Python3.9 - Python3.13 - Ubuntu 22.04 (jammy) Python3.7 - Python3.9, Python3.11 - Python3.13 - Ubuntu 24.04 (noble) Python3.7 - Python3.11, Python3.13 - Note: Python2.7 (focal, jammy), Python 3.8 (focal), Python 3.10 (jammy), Python3.12 (noble) are not provided by deadsnakes as upstream ubuntu provides those packages. Why some packages aren&#39;t built: - Note: for focal, older python versions require libssl<1.1 so they are not currently built - Note: for jammy and noble, older python versions requre libssl<3 so they are not currently built - If you need these, reach out to asottile to set up a private ppa The packages may also work on other versions of Ubuntu or Debian, but that is not tested or supported. Packages ======== The packages provided here are loosely based on the debian upstream packages with some modifications to make them more usable as non-default pythons and on ubuntu. As such, the packages follow debian&#39;s patterns and often do not include a full python distribution with just `apt install python#.#`. Here is a list of packages that may be useful along with the default install: - `python#.#-dev`: includes development headers for building C extensions - `python#.#-venv`: provides the standard library `venv` module - `python#.#-distutils`: provides the standard library `distutils` module - `python#.#-lib2to3`: provides the `2to3-#.#` utility as well as the standard library `lib2to3` module - `python#.#-gdbm`: provides the standard library `dbm.gnu` module - `python#.#-tk`: provides the standard library `tkinter` module Third-Party Python Modules ========================== Python modules in the official Ubuntu repositories are packaged to work with the Python interpreters from the official repositories. Accordingly, they generally won&#39;t work with the Python interpreters from this PPA. As an exception, pure-Python modules for Python 3 will work, but any compiled extension modules won&#39;t. To install 3rd-party Python modules, you should use the common Python packaging tools. For an introduction into the Python packaging ecosystem and its tools, refer to the Python Packaging User Guide: https://packaging.python.org/installing/ Sources ======= The package sources are available at: https://github.com/deadsnakes/ Nightly Builds ============== For nightly builds, see ppa:deadsnakes/nightly https://launchpad.net/~deadsnakes/+archive/ubuntu/nightly More info: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa Press [ENTER] to continue or ctrl-c to cancel removing it huaxi@ubuntu:~/repo$ sudo add-apt-repository ppa:deadsnakes/legacy Cannot add PPA: &#39;ppa:~deadsnakes/ubuntu/legacy&#39;. The team named &#39;~deadsnakes&#39; has no PPA named &#39;ubuntu/legacy&#39; Please choose from the following available PPAs: * &#39;nightly&#39;: nightly python builds * &#39;ppa&#39;: New Python Versions
09-02
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值