首页 > 解决方案 > 在 32 位和 64 位 Python 中导入 PIL(枕头)时出错

问题描述

由于某种原因,我安装了两个 python 版本:3.7.7 32 位和 3.7.8 64 位。特定的行from PIL import Image带来不同的错误。在 64 位中,我收到此错误:

Traceback (most recent call last):
    File "equinox.py", line 20, in <module>
        from PIL import Image, ImageOps,ImageFont, ImageDraw, ImageEnhance
      File "C:\Users\FAMILY\AppData\Roaming\Python\Python37\site-packages\PIL\ImageEnhance.py", line 21, in <module>
        from . import Image, ImageFilter, ImageStat
      File "C:\Users\FAMILY\AppData\Roaming\Python\Python37\site-packages\PIL\ImageFilter.py", line 20, in <module>
        import numpy
      File "C:\Users\FAMILY\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 138, in <module>
        from . import _distributor_init
      File "C:\Users\FAMILY\AppData\Roaming\Python\Python37\site-packages\numpy\_distributor_init.py", line 26, in <module>
        WinDLL(os.path.abspath(filename))
      File "C:\Users\FAMILY\AppData\Local\Programs\Python\Python37\lib\ctypes\__init__.py", line 364, in __init__
        self._handle = _dlopen(self._name, mode)
    OSError: [WinError 193] %1 is not a valid Win32 application

在 32 位中,我收到此错误:ImportError: cannot import _imaging from PIL当它尝试from . import _imaging as core.

我尝试通过重新安装 Python、重新安装 Pillow、删除剩余的 PIL 文件夹、检查已命名_imaging PIL Pillow Image但没有的目录中的任何文件来解决这两个问题。

任何人都可以帮忙吗?

标签: pythonwindowspython-imaging-library

解决方案


推荐阅读