以编程方式查找已安装的 pywin32 版本
某些 Python 包为程序提供了获取已安装版本的方法。例如
>>> import numpy
>>> numpy.version.version
'1.5.0'
,但我找不到 pywin32
这样做的方法。有什么好的办法可以了解一下吗?
Some Python packages provide a way for a program to get the installed version. E.g.
>>> import numpy
>>> numpy.version.version
'1.5.0'
But I can't find a way to do so for pywin32
. What good way might there be to find out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我找到了一篇博客文章 "在 Python 包中包含版本信息” 作者:Jean-Paul Calderone,其中显示您可以通过以下方式获取
pywin32
的版本:I found a blog post "Include version information in your Python packages" by Jean-Paul Calderone which showed you can get the version of
pywin32
this way:改编自 Mark 的官方回复:http://mail.python。 org/pipermail/python-win32/2010-April/010404.html
因为 Craig 的答案在 amd64 版本上不再对我有用。
Adapted from Mark's official response at: http://mail.python.org/pipermail/python-win32/2010-April/010404.html
as Craig's answer no longer worked for me on the amd64 build.
这是迄今为止我想到的唯一方法。它在 Python 安装的
site-packages
目录中找到一个名为pywin32.version.txt
的文件,并读取其中的内容。不过,这距离官方 API 还很远!我不知道
pywin32
的哪些版本安装了该pywin32.version.txt
文件,以及将来继续这种情况的可能性有多大。This is the only way I've figured out so far. It finds a file called
pywin32.version.txt
in the Python installation'ssite-packages
directory, and reads the contents.That's far from an official API, though! I don't know what versions of
pywin32
have installed thatpywin32.version.txt
file, and how likely that is to continue in future.