我使用setuptools安装了Python模块construct和statlib:
sudo apt-get install python-setuptools
sudo easy_install statlib
sudo easy_install construct
如何从命令行检查它们的版本?
我使用setuptools安装了Python模块construct和statlib:
sudo apt-get install python-setuptools
sudo easy_install statlib
sudo easy_install construct
如何从命令行检查它们的版本?
当前回答
你可以试试这个:
pip list
这将输出所有包及其版本。
输出
其他回答
总而言之:
conda list
(它将提供所有的库以及版本细节。)
And:
pip show tensorflow
(它提供了完整的图书馆细节。)
如果您的生产系统被强化到无法理解的地步,所以它既没有pip也没有conda,这里有一个Bash替代pip冻结:
ls /usr/local/lib/python3.8/dist-packages | grep info | awk -F "-" '{print $1"=="$2}' | sed 's/.dist//g'
(请确保将dist-packages文件夹更新到当前的python版本,并忽略不一致的名称,例如,下划线vs.破折号)。
样本打印:
Flask==1.1.2
Flask_Caching==1.10.1
gunicorn==20.1.0
[..]
如果前面答案中的方法不起作用,那么值得在Python中尝试以下方法:
import modulename
modulename.version
modulename.version_info
参见获取Python Tornado版本
注意,除了Tornado之外,.版本也适用于其他几个版本。
像pycharm-terminal一样去终端
现在编写py或python 并按Enter键。
现在你在终端的python中,你可以尝试这样做:
# import <name_of_the_library>
import kivy
# So if the library has __version__ magic method, so this way will help you
kivy.__version__ # then hit Enter to see the version
# Output >> '2.1.0'
但如果上面的方法不奏效,你可以试试这种方法,知道信息包括库的版本
pip show module <HERE PUT THE NAME OF THE LIBRARY>
例子:
pip show module pyperclip
Output:
Name: pyperclip
Version: 1.8.2
Summary: A cross-platform clipboard module for Python. (Only handles plain text for now.)
Home-page: https://github.com/asweigart/pyperclip
Author: Al Sweigart
Author-email: al@inventwithpython.com
License: BSD
Location: c:\c\kivymd\virt\lib\site-packages
Requires:
Required-by:
还有一种方法可以帮助你在项目中显示所有的库和它们的版本:
pip freeze
# I used the above command in a terminal inside my project this is the output
certifi==2021.10.8
charset-normalizer==2.0.12
docutils==0.18.1
idna==3.3
Kivy==2.1.0
kivy-deps.angle==0.3.2
kivy-deps.glew==0.3.1
kivy-deps.sdl2==0.4.5
Kivy-Garden==0.1.5
kivymd @ file:///C:/c/kivymd/KivyMD
Pillow==9.1.0
Pygments==2.12.0
pyperclip==1.8.2
pypiwin32==223
pywin32==303
requests==2.27.1
urllib3==1.26.9
当然,您可以尝试使用下面的命令来显示所有库及其版本
pip list
希望能帮助到大家, 问候
你可以试试这个:
pip list
这将输出所有包及其版本。
输出