我已经搜索了几个小时,但找不到任何东西,所以我想在这里问一下。
所以我的问题是 PIL 和 Pillow。我需要使用 python 2.7,因为我使用的是 Python 3 尚不支持的 SimpleCV。
当我尝试使用 sudo pip uninstall PIL
卸载 PIL 时,它输出:Cannot uninstall requirement PIL, not installed
。
这适用于 python 3,并允许我使用 from PIL import Image
使用 Pillow。如果我尝试使用 import Image
我会得到一个错误,因为它不存在但是,对于 python 2.7(我需要使用的版本),from PIL import Image
和 import Image
的工作让我相信 PIL 还没有从 python 2.7 中卸载。
我认为它没有为 python 2.7 卸载是正确的吗?如果是这样我该如何卸载它?还是其他原因?
提前致谢!
PS:以防万一,我使用的是 Raspberry Pi。
最佳答案
我怀疑您已经成功卸载了 PIL,并且您实际上已经安装了 Pillow。 Pillow 安装在包名 PIL 下。这允许您用 PIL 替换 Pillow,而无需重写任何代码。 Pillow “只是”一个 PIL fork 。
您可以检查是否 import PIL
实际上通过执行加载 Pillow:
import PIL
print PIL.PILLOW_VERSION
如果你安装了 Pillow,它应该输出一些版本。这里说的是 3.3.1,但我用的是 Python3。如果您没有 Pillow,而是 PIL,它应该会导致错误。
更新: 您现在可能会看到如下警告:
<stdin>:1: DeprecationWarning: PILLOW_VERSION is deprecated and will be removed in a future release. Use __version__ instead.
在那种情况下,尝试运行:
print(__PIL.__version__)
关于python - 如何为 python 2.7 卸载 PIL 并改用 Pillow?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40809943/