代码改变世界

【Ubuntu升级python3.5到python3.6】dpkg-deb: error: subprocess paste was killed by signal (Broken pipe) Errors were encountered while processing: E: Sub-process /usr/bin/dpkg returned an error code (1) 问题解决

2019-09-19 16:43  ZealouSnesS  阅读(4172)  评论(0编辑  收藏  举报

 

Ubuntu16.04上将系统自带的python3.5升级到3.6

安装aioredis时提示Python版本需>=3.5.3,所以进行升级
命令如下:

$ sudo add-apt-repository ppa:jonathonf/python-3.6
$ sudo apt-get update
$ sudo apt-get install python3.6*

注意,安装python3.6的时候一定要加*,将3.6所需的依赖库也一起装上

注意,python3.5不要卸载,卸载会损坏系统。

# 移除原3.4link 
$ sudo rm /usr/bin/python3

# 更换默认python3 的版本为3.6
$ sudo ln -s /usr/bin/python3.6 /usr/bin/python3

安装完Python后pip需重新安装:

$ wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
$ sudo python get-pip.py

问题解决

参考:https://askubuntu.com/questions/1037528/apt-get-upgrade-error-for-python-packages-in-ubuntu-16-04

在ubuntu上将python3.5升级到python3.6,执行如下命令时,遇到错误:

sudo apt-get install python3.6*
Building dependency tree       
Reading state information... Done
Note, selecting 'python3.6-2to3' for glob 'python3.6*'
Note, selecting 'python3.6-venv' for glob 'python3.6*'
Note, selecting 'python3.6-examples' for glob 'python3.6*'
Note, selecting 'python3.6' for glob 'python3.6*'
Note, selecting 'python3.6-tk' for glob 'python3.6*'
Note, selecting 'python3.6-lib2to3' for glob 'python3.6*'
Note, selecting 'python3.6-minimal' for glob 'python3.6*'
Note, selecting 'python3.6-gdbm' for glob 'python3.6*'
Note, selecting 'python3.6-dbg' for glob 'python3.6*'
Note, selecting 'python3.6-dev' for glob 'python3.6*'
Note, selecting 'python3.6-doc' for glob 'python3.6*'
Note, selecting 'python3.6-distutils' for glob 'python3.6*'
Note, selecting 'python3-tk' instead of 'python3.6-tk'
Note, selecting 'python3-distutils' instead of 'python3.6-distutils'
Note, selecting 'python3-gdbm' instead of 'python3.6-gdbm'
Note, selecting 'python3-lib2to3' instead of 'python3.6-lib2to3'
python3-gdbm is already the newest version (3.6.5-3~16.04.york4).
python3-tk is already the newest version (3.6.5-3~16.04.york4).
python3.6 is already the newest version (3.6.8-1~16.04.york1).
python3.6-dbg is already the newest version (3.6.8-1~16.04.york1).
python3.6-dev is already the newest version (3.6.8-1~16.04.york1).
python3.6-doc is already the newest version (3.6.8-1~16.04.york1).
python3.6-examples is already the newest version (3.6.8-1~16.04.york1).
python3.6-minimal is already the newest version (3.6.8-1~16.04.york1).
python3.6-venv is already the newest version (3.6.8-1~16.04.york1).
The following NEW packages will be installed:
  python3-distutils python3-lib2to3
0 upgraded, 2 newly installed, 0 to remove and 261 not upgraded.
Need to get 0 B/219 kB of archives.
After this operation, 1,090 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 292643 files and directories currently installed.)
Preparing to unpack .../python3-lib2to3_3.6.5-3~16.04.york0.2_all.deb ...
Unpacking python3-lib2to3 (3.6.5-3~16.04.york0.2) ...
dpkg: error processing archive /var/cache/apt/archives/python3-lib2to3_3.6.5-3~16.04.york0.2_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.6/lib2to3/Grammar.txt', which is also in package libpython3.6-stdlib:amd64 3.6.8-1~16.04.york1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Preparing to unpack .../python3-distutils_3.6.5-3~16.04.york0.2_all.deb ...
Unpacking python3-distutils (3.6.5-3~16.04.york0.2) ...
dpkg: error processing archive /var/cache/apt/archives/python3-distutils_3.6.5-3~16.04.york0.2_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.6/distutils/dir_util.py', which is also in package libpython3.6-stdlib:amd64 3.6.8-1~16.04.york1
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/python3-lib2to3_3.6.5-3~16.04.york0.2_all.deb
 /var/cache/apt/archives/python3-distutils_3.6.5-3~16.04.york0.2_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

对于这种错误,我采取的处理方法是手动强行安装两个安装失败的包(黄底色红字部分):

sudo dpkg --install --force all /var/cache/apt/archives/python3-lib2to3_3.6.5-3~16.04.york0.2_all.deb
sudo dpkg --install --force all /var/cache/apt/archives/python3-distutils_3.6.5-3~16.04.york0.2_all.deb

然后再执行

sudo apt install -f

然后安装就没问题了

sudo apt-get install python3.6*

安装成功!