python3 破坏了 apt 升级

python3 破坏了 apt 升级

我正在尝试升级我的系统但是 python3 正在破坏该过程:

sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 python3 : PreDepends: python3-minimal (= 3.5.1-3) but 3.5.1-4 is installed
           Depends: libpython3-stdlib (= 3.5.1-3) but 3.5.1-4 is installed
E: Unmet dependencies. Try using -f.

因此我使用 -f 重新运行并得到:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
Calculating upgrade... Done
The following packages will be upgraded:
  python3 python3-distupgrade ubuntu-release-upgrader-core ubuntu-release-upgrader-gtk
4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
441 not fully installed or removed.
Need to get 134 kB/143 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 ubuntu-release-upgrader-gtk all 1:16.10.7 [9,292 B]
Get:2 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 ubuntu-release-upgrader-core all 1:16.10.7 [21.2 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu yakkety-updates/main amd64 python3-distupgrade all 1:16.10.7 [103 kB]
Fetched 134 kB in 0s (586 kB/s)                         
Setting up python3-minimal (3.5.1-4) ...
Traceback (most recent call last):
  File "/usr/bin/py3compile", line 290, in <module>
    main()
  File "/usr/bin/py3compile", line 262, in main
    options.optimize, e_patterns)
  File "/usr/bin/py3compile", line 156, in compile
    cfn = interpreter.cache_file(fn, version)
  File "/usr/share/python3/debpython/interpreter.py", line 212, in cache_file
    (fname[:-3], self.magic_tag(version), last_char))
  File "/usr/share/python3/debpython/interpreter.py", line 246, in magic_tag
    return self._execute('import imp; print(imp.get_tag())', version)
  File "/usr/share/python3/debpython/interpreter.py", line 359, in _execute
    raise Exception('{} failed with status code {}'.format(command, output['returncode']))
Exception: python3.5 -c 'import imp; print(imp.get_tag())' failed with status code 1
dpkg: error processing package python3-minimal (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 python3-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)

如果我执行 sudo apt -f install 我会得到:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  python3
Suggested packages:
  python3-doc python3-tk python3-venv
The following packages will be upgraded:
  python3
1 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
441 not fully installed or removed.
Need to get 0 B/8,710 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python3-minimal (3.5.1-4) ...
Traceback (most recent call last):
  File "/usr/bin/py3compile", line 290, in <module>
    main()
  File "/usr/bin/py3compile", line 262, in main
    options.optimize, e_patterns)
  File "/usr/bin/py3compile", line 156, in compile
    cfn = interpreter.cache_file(fn, version)
  File "/usr/share/python3/debpython/interpreter.py", line 212, in cache_file
    (fname[:-3], self.magic_tag(version), last_char))
  File "/usr/share/python3/debpython/interpreter.py", line 246, in magic_tag
    return self._execute('import imp; print(imp.get_tag())', version)
  File "/usr/share/python3/debpython/interpreter.py", line 359, in _execute
    raise Exception('{} failed with status code {}'.format(command, output['returncode']))
Exception: python3.5 -c 'import imp; print(imp.get_tag())' failed with status code 1
dpkg: error processing package python3-minimal (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 python3-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)

如何解决这个问题?

答案1

sudo apt purge -f python3修复了这个问题,系统仍然有python 2.7和3.5

相关内容