安装Python 3.7时出错-E:子进程/ usr / bin / dpkg返回错误代码(1)

问题描述 投票:0回答:1

我试图使用'sudo apt-get install python3.7'在我的Ubuntu虚拟机中安装python 3.7。但是,我得到以下输出:-

Building dependency tree       
Reading state information... Done
python3.7 is already the newest version (3.7.4-2~16.04.york1).
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 libpython3.7 : Depends: libpython3.7-stdlib (= 3.7.4-2~16.04.york1) but 3.7.4-1+xenial2 is to be installed
 libpython3.7-dev : Depends: libpython3.7-stdlib (= 3.7.4-2~16.04.york1) but 3.7.4-1+xenial2 is to be installed
 libpython3.7-stdlib : Depends: libpython3.7-minimal (= 3.7.4-1+xenial2) but 3.7.4-2~16.04.york1 is to be installed
 python3.7 : Depends: libpython3.7-stdlib (= 3.7.4-2~16.04.york1) but 3.7.4-1+xenial2 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

[之后,我尝试按照上面的输出中的建议执行'apt-get -f install',但是随后得到了以下内容:-

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  libpython3.7-stdlib
The following packages will be upgraded:
  libpython3.7-stdlib
1 upgraded, 0 newly installed, 0 to remove and 209 not upgraded.
4 not fully installed or removed.
Need to get 0 B/1,756 kB of archives.
After this operation, 66.6 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 189831 files and directories currently installed.)
Preparing to unpack .../libpython3.7-stdlib_3.7.4-2~16.04.york1_amd64.deb ...
Unpacking libpython3.7-stdlib:amd64 (3.7.4-2~16.04.york1) over (3.7.4-1+xenial2) ...
dpkg: error processing archive /var/cache/apt/archives/libpython3.7-stdlib_3.7.4-2~16.04.york1_amd64.deb (--unpack):
 trying to overwrite '/usr/lib/python3.7/distutils/__init__.py', which is also in package python3.7-distutils 3.7.4-1+xenial2
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.4-2~16.04.york1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

更新:

即使错误表明python3.7已经存在,当我执行python时,也会得到以下信息:

Python 2.7.12 (default, Oct  8 2019, 14:14:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.

以及下面当我运行'python3'时:-

Python 3.5.2 (default, Oct  8 2019, 13:06:37) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.

我要做的就是安装python 3.7。

有人可以帮助我解决此错误吗?

python-3.7 dpkg
1个回答
0
投票

我在您的日志中看到以下内容

python3.7 is already the newest version (3.7.4-2~16.04.york1).

它说已经安装了python3.7。

您可以尝试命令行中的pythonpython3,明白它的意思吗?如果您看到类似下面的内容,则说明它已成功安装

  Python 3.7.3 (v3.7.3 Oct  3 2017, 00:32:08) 
 [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on XXX
 Type "help", "copyright", "credits" or "license" for more information.
© www.soinside.com 2019 - 2024. All rights reserved.