AttributeError: модуль 'PIL.Image' не имеет атрибута 'VERSION' python2 pip

При попытке запустить cinnamon-settings python2 я вижу следующую ошибку:

hutber@hutber:~$ cinnamon-settings python2
Traceback (most recent call last):
  File "/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py", line 619, in <module>
    window = MainWindow()
  File "/usr/share/cinnamon/cinnamon-settings/cinnamon-settings.py", line 247, in __init__
    for module in modules:
  File "/usr/share/cinnamon/cinnamon-settings/modules/cs_backgrounds.py", line 5, in <module>
    import imtools
  File "/usr/share/cinnamon/cinnamon-settings/bin/imtools.py", line 623, in <module>
    if Image.VERSION == '1.1.7':
AttributeError: module 'PIL.Image' has no attribute 'VERSION'

Я видел эту ошибку после установки pip3 install streamdeck_ui --user install

1
задан 25 April 2020 в 18:22

2 ответа

Это известная проблема с версиями между cinnamon и pillow >= 6.0.0. Вы можете найти больше информации здесь. Как сказал предыдущий комментатор, вы можете найти ошибку в /usr/share/cinnamon/cinnamon-settings/bin/imtools.py. Однако изменение Image.VERSION на PIL.VERSION не решит проблему для pillow >= 7.0.0. Вместо этого вы должны изменить строку на if Image.__version__ == '1.1.7':.

2
ответ дан 1 August 2020 в 15:12

Если вам комфортно с python. Вы можете изменить /usr/share/cinnamon/cinnamon-settings/bin/imtools.py.

  1. Сделайте резервную копию файла. т.е.
sudo cp /usr/share/cinnamon/cinnamon-settings/bin/imtools.py /usr/share/cinnamon/cinnamon-settings/bin/imtools.py.bk
  1. Открыть /usr/share/cinnamon/cinnamon-settings/bin/imtools.py с помощью nano
sudo nano /usr/share/cinnamon/cinnamon-settings/bin/imtools.py
  1. Удалить строки с 623 по 636. И сместить линии с 637 на 645 4 пробела влево.

До:

if Image.VERSION == '1.1.7':

    def split(image):
        """Work around for bug in Pil 1.1.7

        :param image: input image
        :type image: PIL image object
        :returns: the different color bands of the image (eg R, G, B)
        :rtype: tuple
        """
        image.load()
        return image.split()
else:

    def split(image):
        """Work around for bug in Pil 1.1.7

        :param image: input image
        :type image: PIL image object
        :returns: the different color bands of the image (eg R, G, B)
        :rtype: tuple
        """
        return image.split()

После:

def split(image):
    """Work around for bug in Pil 1.1.7

    :param image: input image
    :type image: PIL image object
    :returns: the different color bands of the image (eg R, G, B)
    :rtype: tuple
    """
    return image.split()

Проверка версии Image.VERSION 1.1.7 не требуется, если вы используете текущую версию PIL.

0
ответ дан 2 August 2020 в 10:54

Другие вопросы по тегам:

Похожие вопросы: