Python 패키지(Debian)를 설치할 때 dpkg가 오류를 반환합니다.

Python 패키지(Debian)를 설치할 때 dpkg가 오류를 반환합니다.

Debian 저장소에서 pdfshuffler를 설치하려고 시도한 후 종속성 문제와 관련된 오류가 발생했습니다. python-pypdf2 패키지가 필요한 것 같아서 설치를 시도했지만 동일한 오류 메시지가 나타납니다. 유사한 문제를 찾아본 후 apt-get clean, install-f, autoremove 등을 사용해 보았지만 작동하지 않았고 처리 중에 발생한 오류 목록이 계속해서 늘어났습니다. 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)

sudo apt-get installpython-PACKAGE를 사용하려고 하면 비슷한 결과가 나타납니다. 또한 /var/lib/dpkg/status 파일을 편집하여 올바르게 설치되거나 구성되지 않은 Python 패키지의 항목을 제거하려고 시도했지만 도움이 되지 않았습니다(이러한 패키지를 다시 설치하거나 제거하려고 할 때 동일한 문제가 다시 나타났습니다).

어떤 아이디어가 있나요?

감사합니다!

(시스템: Debian Stretch w/KDE Plasma. I7 8500U 16Gb)

다음과 같은필립 브랜드버그댓글, 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

md5sum 확인에 실패했다는 뜻인가요?

답변1

optparse.py따라서 Python 2.7 설치 파일이 손상된 것 같습니다 . 더 구체적으로 말하자면, optparse.py덮어쓰여 Python 3 복사본으로 대체된 것으로 보입니다 .

출력에는 dpkg -V소유자, 그룹, 스키마 등을 확인하는 여러 필드가 표시됩니다. 5출력은 시스템 파일의 MD5 체크섬이 패키지 매니페스트의 항목과 일치하지 않음을 나타냅니다. (즉, 패키지 설치 후 내용이 수정되었습니다.)

이 문제의 원인을 어떻게 알아낼 수 있는지 잘 모르겠습니다... OS 패키지 배포 이외의 다른 것을 사용하여 Python 모듈을 루트로 설치했다면 설명이 될 수 있습니다... 아마도 뭔가를 사용하여 설치했다면 pip? 일반적으로 Python 2와 Python 3 모듈을 분리하는 것이 좋지만 ... 또한 그것이 특별히 관련되는 pip이유도 모르겠습니다 ...optparse.py

어쨌든 이 문제를 해결하려면 apt-get에 패키지를 다시 설치하도록 요청하면 손상 문제를 해결할 수 있습니다.

$ sudo apt-get install --reinstall libpython2.7-minimal

관련 정보