dpkg retorna erro ao instalar o pacote python (Debian)

1

Depois de tentar instalar o pdfshuffler (do repositório Debian) um erro relacionado a problemas de dependência apareceu. Parecia que o pacote python-pypdf2 era necessário, então tentei instalá-lo, mas cheguei à mesma mensagem de erro. Depois de procurar por problemas semelhantes, eu tentei com o apt-get clean, instalar-f, autoremove, etc, mas foi inútil ea lista de erros encontrados durante o processamento continua crescendo. Deixo o erro que recebo após o upgrade do apt-get:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  mendeleydesktop
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
15 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 python-crypto (2.6.1-7) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 27, in <module>
    import optparse
  File "/usr/lib/python2.7/optparse.py", line 1557
    print(self.get_usage(), file=file)
                                ^
SyntaxError: invalid syntax
dpkg: error processing package python-crypto (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up python-wheel (0.29.0-2) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 27, in <module>
    import optparse

  File "/usr/lib/python2.7/optparse.py", line 1557
    print(self.get_usage(), file=file)
                                ^
SyntaxError: invalid syntax
dpkg: error processing package python-wheel (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up python-roman (2.0.0-2) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 27, in <module>
    import optparse
  File "/usr/lib/python2.7/optparse.py", line 1557
    print(self.get_usage(), file=file)
                                ^
SyntaxError: invalid syntax
dpkg: error processing package python-roman (--configure):                                                                                                                                                     
 subprocess installed post-installation script returned error exit status 1                                                                                                                                    
Setting up python-pypdf2 (1.26.0-2) ...                                                                                                                                                                        
Traceback (most recent call last):                                                                                                                                                                             
  File "/usr/bin/pycompile", line 27, in <module>                                                                                                                                                              
    import optparse                                                                                                                                                                                            
  File "/usr/lib/python2.7/optparse.py", line 1557                                                                                                                                                             
    print(self.get_usage(), file=file)                                                                                                                                                                         
                                ^                                                                                                                                                                              
SyntaxError: invalid syntax                                                                                                                                                                                    
dpkg: error processing package python-pypdf2 (--configure):                                                                                                                                                    
 subprocess installed post-installation script returned error exit status 1                                                                                                                                    
dpkg: dependency problems prevent configuration of python-keyrings.alt:                                                                                                                                        
 python-keyrings.alt depends on python-crypto; however:                                                                                                                                                        
  Package python-crypto is not configured yet.                                                                                                                                                                 

dpkg: error processing package python-keyrings.alt (--configure):                                                                                                                                              
 dependency problems - leaving unconfigured                                                                                                                                                                    
Setting up python-gi (3.22.0-2) ...                                                                                                                                                                            
Traceback (most recent call last):                                                                                                                                                                             
  File "/usr/bin/pycompile", line 27, in <module>                                                                                                                                                              
    import optparse
  File "/usr/lib/python2.7/optparse.py", line 1557
    print(self.get_usage(), file=file)
                                ^
SyntaxError: invalid syntax
dpkg: error processing package python-gi (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up python-epydoc (3.0.1+dfsg-14) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 27, in <module>
    import optparse
  File "/usr/lib/python2.7/optparse.py", line 1557
    print(self.get_usage(), file=file)
                                ^
SyntaxError: invalid syntax
dpkg: error processing package python-epydoc (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of pdfshuffler:
 pdfshuffler depends on python-pypdf2 | python-pypdf (>= 1.10); however:
  Package python-pypdf2 is not configured yet.
  Package python-pypdf is not installed.

dpkg: error processing package pdfshuffler (--configure):
 dependency problems - leaving unconfigured
Setting up python-dbus (1.2.4-1+b1) ...
Remove stale byte-compiled files...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 27, in <module>
    import optparse
  File "/usr/lib/python2.7/optparse.py", line 1557
    print(self.get_usage(), file=file)
                                ^
SyntaxError: invalid syntax
dpkg: error processing package python-dbus (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up python-xdg (0.25-4) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 27, in <module>
    import optparse
  File "/usr/lib/python2.7/optparse.py", line 1557
    print(self.get_usage(), file=file)
                                ^
SyntaxError: invalid syntax
dpkg: error processing package python-xdg (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of python-secretstorage:
 python-secretstorage depends on python-dbus; however:
  Package python-dbus is not configured yet.

dpkg: error processing package python-secretstorage (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-docutils:
 python-docutils depends on python-roman; however:
  Package python-roman is not configured yet.

dpkg: error processing package python-docutils (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-keyring:
 python-keyring depends on python-dbus; however:
  Package python-dbus is not configured yet.
 python-keyring depends on python-secretstorage; however:
  Package python-secretstorage is not configured yet.

dpkg: error processing package python-keyring (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-gobject:
 python-gobject depends on python-gi (>= 3.22.0-2); however:
  Package python-gi is not configured yet.

dpkg: error processing package python-gobject (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-poppler:
 python-poppler depends on python-gobject (>= 2.10.1); however:
  Package python-gobject is not configured yet.

dpkg: error processing package python-poppler (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python-crypto
 python-wheel
 python-roman
 python-pypdf2
 python-keyrings.alt
 python-gi
 python-epydoc
 pdfshuffler
 python-dbus
 python-xdg
 python-secretstorage
 python-docutils
 python-keyring
 python-gobject
 python-poppler
E: Sub-process /usr/bin/dpkg returned an error code (1)

Obtém algo semelhante quando tento sudo apt-get install com qualquer pacote de python. Também tentei editar o arquivo / var / lib / dpkg / status, excluindo as entradas de pacotes python não instalados ou configurados corretamente, mas isso não ajudou (o mesmo problema reapareceu ao tentar reinstalar ou remover esses pacotes).

Alguma ideia?

Obrigado!

(Sistema: Debian Stretch com Plasma do KDE. I7 8500U 16Gb)

Seguindo os comentários da Filipe Branderburger , procurei por erros em optparse.py:

eric@debian:~$ dpkg -S /usr/lib/python2.7/optparse.py
libpython2.7-minimal:amd64: /usr/lib/python2.7/optparse.py
eric@debian:~$ dpkg -V libpython2.7-minimal
??5??????   /usr/lib/python2.7/optparse.py
eric@debian:~$ ls -l /usr/lib/python2.7/optparse.py
-rw-r--r-- 1 eric eric 60337 Mar 20 00:01 /usr/lib/python2.7/optparse.py
eric@debian:~$ readlink -f /usr/lib/python2.7/optparse.py
/usr/lib/python2.7/optparse.py

Isso significa que a verificação do md5sum falhou?

    
por E Speranza 14.04.2018 / 20:56

1 resposta

0

Portanto, parece que o arquivo optparse.py da sua instalação do Python 2.7 foi corrompido. Mais especificamente, parece ter sido sobrescrito e substituído por uma cópia de optparse.py do Python 3.

A saída de dpkg -V mostra muitos campos verificando proprietário, grupo, modo, etc. O 5 na saída indica que a soma de verificação MD5 do arquivo no sistema não corresponde àquela no manifesto do pacote. (Em outras palavras, o conteúdo foi modificado depois que o pacote foi instalado.)

Não tenho certeza de como você pode descobrir o que pode ter causado isso ... Se você instalou módulos Python, como root, usando algo diferente de seu O.S. distribuição de pacotes, que poderia explicar isso ... Talvez se você instalou algo usando pip ? Embora pip seja bom em manter os módulos do Python 2 e do Python 3 separados ... Além disso, não vejo por que ele tocaria optparse.py especificamente ...

Em qualquer caso, para corrigir esse problema, você poderia pedir ao apt-get para reinstalar o pacote, o que deve corrigir a corrupção:

$ sudo apt-get install --reinstall libpython2.7-minimal
    
por 16.04.2018 / 01:54