以下软件包有未满足的依赖项 python 3.7

以下软件包有未满足的依赖项 python 3.7

尝试时随机出现此错误sudo apt-get upgrade,并且已尝试运行 apt-get -f安装但没有成功,我该怎么办?

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:
 libpython3.7-stdlib : Depends: libpython3.7-minimal (= 3.7.3-1+xenial1) but 3.7.3-2~16.04.york0 is installed
 python3.7 : Depends: libpython3.7-stdlib (= 3.7.3-2~16.04.york0) but 3.7.3-1+xenial1 is installed
E: Unmet dependencies. Try using -f.

编辑:

apt policy python3.7 libpython3.7-stdlib libpython3.7-minimal输出

python3.7:
  Installed: 3.7.3-2~16.04.york0
  Candidate: 3.7.3-2~16.04.york0
  Version table:
 *** 3.7.3-2~16.04.york0 500
        500 http://ppa.launchpad.net/jonathonf/python-3.7/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status
     3.7.3-1+xenial1 500
        500 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu xenial/main amd64 Packages
libpython3.7-stdlib:
  Installed: 3.7.3-1+xenial1
  Candidate: 3.7.3-2~16.04.york0
  Version table:
     3.7.3-2~16.04.york0 500
        500 http://ppa.launchpad.net/jonathonf/python-3.7/ubuntu xenial/main amd64 Packages
 *** 3.7.3-1+xenial1 500
        500 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status
libpython3.7-minimal:
  Installed: 3.7.3-2~16.04.york0
  Candidate: 3.7.3-2~16.04.york0
  Version table:
 *** 3.7.3-2~16.04.york0 500
        500 http://ppa.launchpad.net/jonathonf/python-3.7/ubuntu xenial/main amd64 Packages
        100 /var/lib/dpkg/status
     3.7.3-1+xenial1 500
        500 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu xenial/main amd64 Packages

sudo apt install libpython3.7-stdlib输出

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  python3.7-distutils python3.7-lib2to3
Use 'sudo apt autoremove' to remove them.
The following packages will be upgraded:
  libpython3.7-stdlib
1 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
1 not fully installed or removed.
Need to get 0 B/1748 kB of archives.
After this operation, 91,1 kB disk space will be freed.
(Reading database ... 303775 files and directories currently installed.)
Preparing to unpack .../libpython3.7-stdlib_3.7.3-2~16.04.york0_amd64.deb ...
Unpacking libpython3.7-stdlib:amd64 (3.7.3-2~16.04.york0) over (3.7.3-1+xenial1) ...
dpkg: error processing archive /var/cache/apt/archives/libpython3.7-stdlib_3.7.3-2~16.04.york0_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.7/distutils/__init__.py', which is also in package python3.7-distutils 3.7.3-1+xenial1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/libpython3.7-stdlib_3.7.3-2~16.04.york0_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

诊断:

看看怎么sudo apt upgrade说:

myself@box:~$ sudo apt upgrade
[sudo] password for myself: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libpython3.7-stdlib : Depends: libpython3.7-minimal (= 3.7.13-1+bionic1) but 3.7.13-1+bionic3 is installed
 python3.7 : Depends: libpython3.7-stdlib (= 3.7.13-1+bionic3) but 3.7.13-1+bionic1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

结论:一些 Python 3.7 包有问题。


概述-一个 Python 版本:

列出所有 Python 3.7 软件包。最好在实施解决方案之前和之后比较此列表。

# Command:
sudo dpkg -l | grep 'python3\.7' | awk '{print $2}'

# Output:
libpython3.7-minimal:amd64
libpython3.7-stdlib:amd64
python3.7
python3.7-distutils
python3.7-lib2to3
python3.7-minimal
python3.7-venv

解决方案-一个Python版本:

无需删除/清除 deadsnakes ppa。这对我在 Ubuntu 18.04 上有效

  1. 发出此命令来删除所有 Python 3.7 包:

     myself@box:~$ sudo apt --fix-missing purge $(dpkg -l | grep 'python3\.7' | awk '{print $2}')
    
  2. 回答Y执行列出的包的删除。

  3. 再次安装相同的软件包:

    • 替代方案 A) 较慢且更智能的版本:仅安装您知道要安装的软件包,它们将由 apt 设置为手动安装:

       myself@box:~$ sudo apt install python3.7 python3.7-venv
      

      看看其他软件包是否作为依赖项自动安装。如果没有,请手动安装其他缺失的软件包。

    • 替代方案 B) 更快更笨的版本:从创建的列表中复制软件包名称apt --fix-missing purge,删除星号并(再次)安装它们:

      myself@box:~$ sudo apt install libpython3.7-minimal libpython3.7-stdlib python3.7 python3.7-minimal python3.7-venv
      
  4. 不是必须的:请与概述-从上面命令您现在已经安装了与实施解决方案之前相同的软件包。


概述——几个 Python 版本:

列出所需的所有 Python 版本的所有软件包,对我来说是 3.7、3.10 和 3.11。最好在实施解决方案之前和之后比较此列表。

sudo dpkg -l | grep 'python3\.7\|python3\.10\|python3\.11' | awk '{print $2}'

解决方案——同时使用多个 Python 版本:

  1. 按照上面的方法操作,但改用这个命令。填写失败的 Python 版本。对我来说,它们是 3.7、3.10 和 3.11

     sudo apt --fix-missing purge $(dpkg -l | grep 'python3\.7\|python3\.10\|python3\.11' | awk '{print $2}')
    
  2. 回答Y

  3. 再次安装 Python。我没有或不需要 3.11 版的 venv,因此:

     sudo apt install python3.11 python3.10 python3.10-venv python3.7 python3.7-venv
    
  4. 不是必须的:请与概述-从上面命令您现在已经安装了与实施解决方案之前相同的软件包。


命令(#1)各部分的来源和解释可在此处找到https://askubuntu.com/a/1402567

答案2

考虑删除有问题的 PPA 并使用以下命令重新安装正常软件包:

sudo apt-get install ppa-purge
sudo ppa-purge ppa:jonathonf/python-3.7
sudo ppa-purge ppa:deadsnakes/ppa
sudo apt-get install --reinstall libpython3.5-minimal python3-minimal python3.5-minimal
sudo apt-get install --reinstall libpython3-stdlib libpython3.5-stdlib

答案3

好的,看来你使用了另一个具有更高版本软件包的 PPA,然后将其从你的 中删除sources.list。无法通过 apt 降级整个软件包版本。因此,你需要回退到你使用的 PPA:

sudo add-apt-repository ppa:jonathonf/python-3.7
sudo apt-get update
sudo apt-get upgrade

相关内容