记录一次升级报错和解决过程

最近升级一直出现如下报错:

└──╼ #apt install gconf2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gconf2 is already the newest version (3.2.6-4.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up gconf2 (3.2.6-4.1) ...
Traceback (most recent call last):
  File "/usr/bin/update-gconf-defaults", line 180, in <module>
    read_entries(realname)
  File "/usr/bin/update-gconf-defaults", line 139, in read_entries
    for line in file(filename):
NameError: name 'file' is not defined
dpkg: error processing package gconf2 (--configure):
 installed gconf2 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 gconf2
Configuring sandbox profiles....
Sandbox profiles updated!
E: Sub-process /usr/bin/dpkg returned an error code (1)

前几次没太在意,以为再遇到几次升级就会好的,然而并未随我的愿望,多次升级以后还是在最后抛出这个gconf2错误,并且gcon2还导致了atom升级也跟着失败了。
想来想去问题已经得寸进尺引入新的报错了,有必要多花心思看一下原因了,几轮网上搜索报错关键字也没升到什么线索,再仔细看错误的/usr/bin/update-gconf-defaults脚本,打开后一看是python写的,文件开头指定是python但并未指定python的大版本号。
至此就感觉到原因差不多要找到了,因为回想近期做测试用的python3,有过改动系统的python版本从默认的2配置到了3,研究一下出错行的内容发现python3与2在file函数上还是有一定区别的,版本3为open(…),果断切换回2.7再执行一次升级,问题解决。

└──╼ #update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path              Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3   3         auto mode
  1            /usr/bin/python2   2         manual mode
  2            /usr/bin/python3   3         manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/python2 to provide /usr/bin/python (python) in manual mode

#重新安装和更新
┌─[root@johnson]─[/home/lee]
└──╼ #apt install gconf2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gconf2 is already the newest version (3.2.6-4.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up gconf2 (3.2.6-4.1) ...
Configuring sandbox profiles....
Sandbox profiles updated!
W: APT had planned for dpkg to do more than it reported back (0 vs 4).
   Affected packages: gconf2:amd64
┌─[root@xxx]─[/home/xxx]
└──╼ #apt full-upgrade -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
┌─[root@xxx]─[/home/xxx]
└──╼ #apt install atom
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  atom
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/86.7 MB of archives.
After this operation, 86.7 MB of additional disk space will be used.
Selecting previously unselected package atom.
(Reading database ... 499068 files and directories currently installed.)
Preparing to unpack .../atom_1.26.1-1~webupd8~0_amd64.deb ...
Unpacking atom (1.26.1-1~webupd8~0) ...
Setting up atom (1.26.1-1~webupd8~0) ...
Processing triggers for mime-support (3.60) ...
Processing triggers for desktop-file-utils (0.23-3) ...
Processing triggers for bamfdaemon (0.5.3-2+b1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Configuring sandbox profiles....
Sandbox profiles updated!

1 个赞

Python2与Python3的区别可参考前人整理的内容,详见链接
Python2与3的区别整理

1 个赞

py2和3对我来说的区别就是py3更麻烦。。习惯了py2 print xxx这种简洁的方法,py3 print变成了函数。。。必须要加括号

不过用了py3很少遇见py2的unicode error

1 个赞

其实我对这些细节像脸盲一样没多少概念,自从不做程序员之后就成了遇到什么语言就搞什么语言,遇到什么版本的就搞什么版本,用到什么算法就各种找类库或包引用,遇到啥错误baidu不行就bing再不行就爱国google,算是跳出专职程序员的坑又进入大杂烩的苦逼运维境遇,人生就是这般如此又那么难以琢磨 :face_with_raised_eyebrow::face_with_raised_eyebrow::face_with_raised_eyebrow:

1 个赞

服务器资源由ZeptoVM赞助

Partners Wiki Discord