如何获得 Python Pillow (PIL) 版本? [英] How to get Python Pillow (PIL) version?

查看:244
本文介绍了如何获得 Python Pillow (PIL) 版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Mac OS 上安装 PIL(Python 成像库)版本X电脑.我之前安装了 Pillow,这是一个更友好的 PIL 分支.

我试过了:

导入PIL打印('PIL',PIL.__version__)

我有错误:

AttributeError: 模块 'PIL' 没有属性 '__version__'

解决方案

使用PIL.__version__.

Pillow 6.0.0 版之前,可以通过以下变量访问其版本字符串名称:

<预><代码>>>>PIL.version.__version__'5.1.0'>>>PIL.PILLOW_VERSION'5.1.0'>>>PIL.__版本__'5.1.0'>>>

不要与 Pillow 构建的最后一个 PIL 版本混淆(并因此挂起):

<预><代码>>>>版本'1.1.7'

关于 PIL 的 fork 的文档中没有关于此的信息:https://pillow.readthedocs.io/en/5.1.x/about.html#why-a-fork

但是,PIL 的主页声明

<块引用>

状态
当前的免费版本是 PIL 1.1.7.此版本支持 Python 1.5.2 > 及更新版本,包括 2.5 和 2.6.3.X 版本稍后发布.

该版本发布日期为2009 年 11 月 15 日".

这证实它只是 PIL 的最后一个发布版本.

<小时>为未来/进一步挖掘:

版本字符串在这些源文件中定义:https://github.com/python-pillow/Pillow/blob/master/src/PIL/version.pyhttps://github.com/python-pillow/Pillow/blob/master/src/PIL/__init__.py搜索所有出现__version__ 在存储库中.

(在我的 Windows 上,它安装到 %LocalAppData%\Programs\Python\Python36\Lib\site-packages\PIL\version.py)

<小时>更新

https://pillow.readthedocs.io/en/stable/releasenotes/5.2.0.html

<块引用>

5.2.0 API 更改弃用

这些版本常量已被弃用.VERSION 将被删除在 Pillow 6.0.0 中,之后 PILLOW_VERSION 将被删除.

`PIL.VERSION`(旧 PIL 版本 1.1.7)`PIL.PILLOW_VERSION``PIL.Image.VERSION``PIL.Image.PILLOW_VERSION`

改用PIL.__version__.

https://pillow.readthedocs.io/en/stable/releasenotes/6.0.0.html

<块引用>

6.0.0 向后不兼容的变化

删除不推荐使用的版本

VERSION(旧的 PIL 版本,始终为 1.1.7)已被删除.用__version__ 代替.

I would like to get the PIL (Python Imaging Library) version installed on a Mac OS X computer. I've previously installed Pillow, a more friendly fork of PIL.

I've tried:

import PIL
print('PIL',PIL.__version__)

And I've got the error:

AttributeError: module 'PIL' has no attribute '__version__'

解决方案

Use PIL.__version__.

Before Pillow version 6.0.0, its version string could be accessed via the following variable names:

>>> PIL.version.__version__
'5.1.0'
>>> PIL.PILLOW_VERSION
'5.1.0'
>>> PIL.__version__
'5.1.0'
>>>

Not to be confused with the last PIL version that Pillow is built on (and thus hangs on to):

>>> PIL.VERSION
'1.1.7'

There was no information on this in the documentation regarding the fork from PIL: https://pillow.readthedocs.io/en/5.1.x/about.html#why-a-fork

However, PIL's homepage states

Status
The current free version is PIL 1.1.7. This release supports Python 1.5.2 >and newer, including 2.5 and 2.6. A version for 3.X will be released later.

That release is dated "November 15, 2009".

This confirms it's just PIL's last release version.


For future/further digging:

The version string is defined in these source files: https://github.com/python-pillow/Pillow/blob/master/src/PIL/version.py and https://github.com/python-pillow/Pillow/blob/master/src/PIL/__init__.py, or search for all occurences of __version__ in the repository.

(On my Windows, this is installed to %LocalAppData%\Programs\Python\Python36\Lib\site-packages\PIL\version.py)


Update

https://pillow.readthedocs.io/en/stable/releasenotes/5.2.0.html

5.2.0 API Changes Deprecations

These version constants have been deprecated. VERSION will be removed in Pillow 6.0.0, and PILLOW_VERSION will be removed after that.

`PIL.VERSION` (old PIL version 1.1.7)
`PIL.PILLOW_VERSION`
`PIL.Image.VERSION`
`PIL.Image.PILLOW_VERSION`

Use PIL.__version__ instead.

https://pillow.readthedocs.io/en/stable/releasenotes/6.0.0.html

6.0.0 Backwards Incompatible Changes

Removed deprecated VERSION

VERSION (the old PIL version, always 1.1.7) has been removed. Use __version__ instead.

这篇关于如何获得 Python Pillow (PIL) 版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆