Пакет Python «шесть» тормозит apt-команды

Я использую Ubuntu 20.04.01 и недавно начал работать с Python.

Один из проектов, над которым я работаю, потребовал от меня установки шести, библиотеки совместимости Python 2 и 3.

pip show six возвращает мне:

Name: six
Version: 1.15.0
Summary: Python 2 and 3 compatibility utilities
Home-page: https://github.com/benjaminp/six
Author: Benjamin Peterson
Author-email: [email protected]
License: MIT
Location: /home/username/.local/lib/python3.8/site-packages
Requires: 
Required-by: Represent, cycler, launchpadlib

Однако каждый раз, когда я запускаю любую из следующих команд: apt upgrade -y apt autoremove и так далее, я получаю следующую ошибку:

sudo apt autoremove                                     
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances       
Lecture des informations d'état... Fait
0 mis à jour, 0 nouvellement installés, 0 à enlever et 2 non mis à jour.
3 partiellement installés ou enlevés.
Après cette opération, 0 o d'espace disque supplémentaires seront utilisés.
Paramétrage de update-notifier-common (3.192.30) ...
Traceback (most recent call last):
  File "/usr/lib/update-notifier/package-data-downloader", line 351, in <module>
    process_download_requests()
  File "/usr/lib/update-notifier/package-data-downloader", line 250, in process_download_requests
    for para in hook.iter_paragraphs(open(file)):
  File "/usr/lib/python3/dist-packages/debian/deb822.py", line 717, in iter_paragraphs
    x = cls(iterable, fields, encoding=encoding, strict=strict)
  File "/usr/lib/python3/dist-packages/debian/deb822.py", line 632, in __init__
    self._internal_parser(iterable, fields, strict)
  File "/usr/lib/python3/dist-packages/debian/deb822.py", line 769, in _internal_parser
    if isinstance(sequence, (six.string_types, bytes)):
NameError: name 'six' is not defined
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 72, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 32, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 12, in <module>
    import os, glob, subprocess, os.path, time, pwd, sys, requests_unixsocket
  File "/usr/lib/python3/dist-packages/requests_unixsocket/__init__.py", line 1, in <module>
    import requests
  File "/usr/lib/python3/dist-packages/requests/__init__.py", line 43, in <module>
    import urllib3
  File "/usr/lib/python3/dist-packages/urllib3/__init__.py", line 7, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 11, in <module>
    from .exceptions import (
  File "/usr/lib/python3/dist-packages/urllib3/exceptions.py", line 2, in <module>
    from six.moves.http_client import IncompleteRead as httplib_IncompleteRead
ModuleNotFoundError: No module named 'six'

Original exception was:
Traceback (most recent call last):
  File "/usr/lib/update-notifier/package-data-downloader", line 351, in <module>
    process_download_requests()
  File "/usr/lib/update-notifier/package-data-downloader", line 250, in process_download_requests
    for para in hook.iter_paragraphs(open(file)):
  File "/usr/lib/python3/dist-packages/debian/deb822.py", line 717, in iter_paragraphs
    x = cls(iterable, fields, encoding=encoding, strict=strict)
  File "/usr/lib/python3/dist-packages/debian/deb822.py", line 632, in __init__
    self._internal_parser(iterable, fields, strict)
  File "/usr/lib/python3/dist-packages/debian/deb822.py", line 769, in _internal_parser
    if isinstance(sequence, (six.string_types, bytes)):
NameError: name 'six' is not defined
dpkg: erreur de traitement du paquet update-notifier-common (--configure) :
 installed update-notifier-common package post-installation script subprocess returned error exit status 
1
Aucun rapport « apport » n'a été créé car le message d'erreur indique une erreur consécutive à un échec p
récédent.
         dpkg: des problèmes de dépendances empêchent la configuration de flashplugin-installer :
 flashplugin-installer dépend de update-notifier-common (>= 0.119ubuntu2) ; cependant :
 Le paquet update-notifier-common n'est pas encore configuré.

dpkg: erreur de traitement du paquet flashplugin-installer (--configure) :
 problèmes de dépendances - laissé non configuré
dpkg: des problèmes de dépendances empêchent la configuration de ttf-mscorefonts-installer :
 ttf-mscorefonts-installer dépend de update-notifier-common (>= 0.119ubuntu2) ; cependant :
 Le paquet update-notifier-common n'est pas encore configuré.

dpkg: erreur de traitement du paquet ttf-mscorefonts-installer (--configure) :
 problèmes de dépendances - laissé non configuré
Aucun rapport « apport » n'a été créé car le message d'erreur indique une erreur consécutive à un échec p
récédent.
         Des erreurs ont été rencontrées pendant l'exécution :
 update-notifier-common
 flashplugin-installer
 ttf-mscorefonts-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)

Я попытался удалить пакет и снова установить его, используя версию pip 20.0.2, но возникает та же ошибка. Даже если пакет отсутствует в системе, я получаю сообщение об ошибке.

Я попытался зайти в файлы, возвращающие ошибку (/usr/lib/python3/dist-packages/debian/deb822.py), и выяснить, что было не так, удалив строки, где появилось «шесть» (я знаю, что это очень плохая практика но файлы резервных копий делались все время, и я хотел посмотреть, смогу ли я это исправить самостоятельно), но это оказалось безуспешным и было отчаянной попыткой.

Вы знаете, как это исправить? Любая помощь будет принята с благодарностью.


person A .Guillot    schedule 19.11.2020    source источник
comment
Это может быть возможным решением. Для справки в будущем, как правило, не рекомендуется возиться с установленным в системе python, используйте виртуальную среду, чтобы отделить ваш python от системного   -  person C.Nivs    schedule 19.11.2020


Ответы (1)


Я столкнулся с аналогичной проблемой при обновлении системы (Ubuntu-Server 18.04, первоначально установленный в 16.04).

# apt upgrade
Traceback (most recent call last):
  File "/usr/lib/update-notifier/package-data-downloader", line 24, in <module>
    import debian.deb822
  File "/usr/lib/python3/dist-packages/debian/deb822.py", line 49, in <module>
    import six
ModuleNotFoundError: No module named 'six'
dpkg: erreur de traitement du paquet update-notifier-common (--configure) :
installed update-notifier-common package post-installation script subprocess returned error exit status 1
dpkg: des problèmes de dépendances empêchent la configuration de ubuntu-server :
   ubuntu-server dépend de update-notifier-common ; cependant :
   Le paquet update-notifier-common n'est pas encore configuré.

как было предложено на forum.ubuntu-fr.org, я попытался очистить, а затем переустановить проблемные пакеты: update-manager, update-notifier, update-notifier-common.

apt purge update-manager update-notifier update-notifier-common
reboot
apt purge update-manager update-notifier update-notifier-common
apt update
apt upgrade

с этого момента ошибок больше не было... но когда я снова попытался установить пакеты update-manager, update-notifier и update-notifier-common, то получил новые ошибки!

apt install update-manager update-notifier update-notifier-common
  Des erreurs ont été rencontrées pendant l'exécution :
   update-notifier-common
   update-notifier
   update-manager
 ubuntu-release-upgrader-gtk
E: Sub-process /usr/bin/dpkg returned an error code (1)

Поэтому я навсегда удалил эти пакеты.

apt purge update-manager update-notifier update-notifier-common

для информации, вот содержимое /etc/apt/sources.list.

# grep bionic /etc/apt/sources.list
deb http://fr.archive.ubuntu.com/ubuntu/ bionic main restricted
deb http://fr.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb http://fr.archive.ubuntu.com/ubuntu/ bionic universe
deb http://fr.archive.ubuntu.com/ubuntu/ bionic-updates universe
deb http://fr.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://fr.archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb http://fr.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
person MaxiReglisse    schedule 28.01.2021