python 模块 版本_如何检查python模块的版本?

本文介绍了如何使用Python的包管理器PIP来检查已安装模块的版本。除了直接使用`pip show`命令,还提到了一种不使用PIP的验证方法,但当需要检查多个模块版本时,使用PIP的方法更为便捷。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

python 模块 版本

The ideal way of installing python libraries are using PIP (Python Package Manager). PIP provides an option to verify the version of the installed modules.

安装python库的理想方法是使用PIP(Python软件包管理器)。 PIP提供了一个选项来验证已安装模块的版本。

The command to use to verify the version of the installed modules is:

用于验证已安装模块版本的命令为

    pip freeze

(venv) bash$:src XYZ$ pip freeze
notebook==6.0.2
numpy==1.17.2
openpyxl==3.0.2
pandas==0.25.3
pandocfilters==1.4.2
parso==0.5.2
pexpect==4.7.0
pickleshare==0.7.5
prometheus-client==0.7.1
prompt-toolkit==3.0.2
ptyprocess==0.6.0
Pygments==2.5.2
pynb==0.1.36
pyrsistent==0.15.6
python-dateutil==2.8.1
pytz==2019.3
pyzmq==18.1.1
qtconsole==4.6.0
Send2Trash==1.5.0
six==1.13.0
soupsieve==1.9.5
SQLAlchemy==1.3.12
terminado==0.8.3
testpath==0.4.4
tornado==6.0.3
traitlets==4.3.3
wcwidth==0.1.8
webencodings==0.5.1
widgetsnbextension==3.5.1

The above list might be very exhaustive and in order to verify the version of a given module use the below command,

上面的列表可能非常详尽,为了验证给定模块的版本,请使用以下命令,

(venv) bash:src XYZ$ pip freeze | grep pandas
pandas==0.25.3

Another option to verify the version of the module (without using PIP) is as follows,

验证模块版本(不使用PIP)的另一种方法如下:

# import the module 
import pandas as pd 

# print the version 
print(pd.__version__)

Output

输出量

0.25.3

The above method is cumbersome in case we want to verify the version of multiple modules, as we have to write a print statement for every module. Hence the PIP way of verifying the version is preferred.

如果我们要验证多个模块的版本,上述方法比较麻烦,因为我们必须为每个模块编写一条打印语句。 因此,首选使用PIP验证版本。

翻译自: https://www.includehelp.com/python/how-to-check-version-of-python-modules.aspx

python 模块 版本

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值