我的电脑断电了,apt 的某个东西也坏了(可能与 python 有关),最初我甚至无法完成这个操作,sudo apt update
但与此相比我已经取得了很大进展,但现在尝试安装 system76-driver 时失败了,我被卡住了。
我已经尝试过的东西,重新安装,卸载/清除。(与下面相同的错误)
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
输入:
sudo apt upgrade -y
输出:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
libodbc1
The following packages will be upgraded:
system76-driver
1 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/54.2 kB of archives.
After this operation, 4,096 B of additional disk space will be used.
(Reading database ... 406541 files and directories currently installed.)
Preparing to unpack .../system76-driver_19.10.1~1579103503~18.04~966d6c0~dev_all.deb ...
Fatal Python error: non-string found in code slot
Current thread 0x00007fd5ce9e5740 (most recent call first):
File "<frozen importlib._bootstrap_external>", line 487 in _compile_bytecode
File "<frozen importlib._bootstrap_external>", line 779 in get_code
File "<frozen importlib._bootstrap_external>", line 674 in exec_module
File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971 in _find_and_load
File "/usr/share/python3/debpython/__init__.py", line 2 in <module>
File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 678 in exec_module
File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971 in _find_and_load
File "/usr/bin/py3clean", line 32 in <module>
Aborted
dpkg: warning: old system76-driver package pre-removal script subprocess returned error exit status 134
dpkg: trying script from the new package instead ...
Fatal Python error: non-string found in code slot
Current thread 0x00007faf80c0b740 (most recent call first):
File "<frozen importlib._bootstrap_external>", line 487 in _compile_bytecode
File "<frozen importlib._bootstrap_external>", line 779 in get_code
File "<frozen importlib._bootstrap_external>", line 674 in exec_module
File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971 in _find_and_load
File "/usr/share/python3/debpython/__init__.py", line 2 in <module>
File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 678 in exec_module
File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971 in _find_and_load
File "/usr/bin/py3clean", line 32 in <module>
Aborted
dpkg: error processing archive /var/cache/apt/archives/system76-driver_19.10.1~1579103503~18.04~966d6c0~dev_all.deb (--unpack):
new system76-driver package pre-removal script subprocess returned error exit status 134
Fatal Python error: non-string found in code slot
Current thread 0x00007f27ca520740 (most recent call first):
File "<frozen importlib._bootstrap_external>", line 487 in _compile_bytecode
File "<frozen importlib._bootstrap_external>", line 779 in get_code
File "<frozen importlib._bootstrap_external>", line 674 in exec_module
File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971 in _find_and_load
File "/usr/share/python3/debpython/__init__.py", line 2 in <module>
File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 678 in exec_module
File "<frozen importlib._bootstrap>", line 665 in _load_unlocked
File "<frozen importlib._bootstrap>", line 955 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971 in _find_and_load
File "<frozen importlib._bootstrap>", line 219 in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 941 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 971 in _find_and_load
File "/usr/bin/py3compile", line 34 in <module>
Aborted
Errors were encountered while processing:
/var/cache/apt/archives/system76-driver_19.10.1~1579103503~18.04~966d6c0~dev_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
看来这只是我已经解决的原始问题(无法 apt update)的遗留问题,只需要我重启电脑就可以解决所有问题。对于任何好奇的人来说,最初的问题是在运行 apt update 时,我会收到一个致命的 Python 错误:在代码槽中发现非字符串,然后出现一些与上述错误类似的错误。如果我没记错的话,因为我花了几个小时来解决这个问题,所以我在它起作用之前做的最后一件事是
sudo rm -rf /var/lib/dpkg/updates/*
sudo rm -rf /var/lib/apt/lists/*
sudo rm /var/cache/apt/*.bin
sudo apt-get clean
sudo apt-get autoremove
sudo apt-get update
这允许更新工作但升级失败,直到重新启动。