AttributeError:模块‘PIL.Image’没有属性‘VERSION’python2 pip

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

这是 cinnamon 和 之间的已知版本问题pillow >= 6.0.0。您可以找到更多信息这里。正如之前的评论者所说,您可以在 中找到错误/usr/share/cinnamon/cinnamon-settings/bin/imtools.py。但是,更改Image.VERSIONPIL.VERSION并不能解决 的问题pillow >= 7.0.0。您必须将行更改为if Image.__version__ == '1.1.7':

答案2

如果你熟悉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()

如果您正在使用当前版本的 PIL,则不需要检查版本 Image.VERSION 1.1.7。

相关内容