告诉我Python构建时所使用的zlib版本。

3

我怎么知道Python的zlib模块是使用哪个版本的C库编译的呢?

具体来说,我想知道它是否是新版本,支持ZLIB_RSYNC=1。

这与zlib python 模块的版本不同,而是与底层C库的版本相关。

3个回答

4

这是 zlib.ZLIB_VERSION

>>> import zlib
>>> zlib.ZLIB_VERSION
'1.2.7'

显然我想要的RYSNC功能是一个贡献补丁,从未合并。 - ʞɔıu

1

尝试下面的命令,以查看是否可用 zlip Python 包,以及它的版本:

  • 对于 Python 2.x:
python -c "import zlib; print(zlib.__version__)"
  • 对于Python 3.x:
python3 -c "import zlib; print(zlib.__version__)"

0

对于c语言(推荐):

cat > get_zlib_version.c << EOF
#include<stdio.h>
#include<zlib.h>

int main()
{
    printf("%s", ZLIB_VERSION);
    return 0;
}
EOF

gcc get_zlib_version.c -o get_zlib_version && ./get_zlib_version

对于Python 2.x:

# only show zlib version used for building the module, this may be different from the zlib library actually used at runtime
python -c "import zlib; print(zlib.ZLIB_VERSION)"

对于 Python 3.x:

# The version string of the zlib library actually loaded by the interpreter.
python -c "import zlib; print(zlib.ZLIB_RUNTIME_VERSION)"

https://docs.python.org/3/library/zlib.html


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接