Python PIL 与图像的兼容性

问题描述 投票:0回答:1

要使用图像,我执行了以下操作:

pip install pil

from PIL import Image

但是很多程序只想要图像:

import Image

我该如何使用

import Image

python image macos python-imaging-library
1个回答
2
投票

基本上您可以使用这里提到的任何方法。

在我的 Linux 安装中,PIL 已经使用了其中之一 - 有一个名为 PILcompat 的目录,其中包含 Image.py 等文件,以及一个名为 PILcompat.pth 的文件,用于告诉 python 将此目录添加到其模块搜索路径中。 这样当

 import Image 

执行后,python找到PILcompat/Image.py执行其内容-

 from PIL.Image import *

我猜测您的计算机上缺少 .pth 文件或目录。

© www.soinside.com 2019 - 2024. All rights reserved.