import subprocess as spprint(sp.getoutput(python3 --version))
# Or however it suits your needs!py3_version = sp.getoutput(python3 --version)
def check_version(name, version):...
check_version('python3', py3_version)
# 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: pyperclipVersion: 1.8.2Summary: A cross-platform clipboard module for Python. (Only handles plain text for now.)Home-page: https://github.com/asweigart/pyperclipAuthor: Al SweigartAuthor-email: al@inventwithpython.comLicense: BSDLocation: c:\c\kivymd\virt\lib\site-packagesRequires:Required-by:
还有另一种方法可以帮助您在项目中显示所有库和它们的版本:
pip freeze# I used the above command in a terminal inside my project this is the outputcertifi==2021.10.8charset-normalizer==2.0.12docutils==0.18.1idna==3.3Kivy==2.1.0kivy-deps.angle==0.3.2kivy-deps.glew==0.3.1kivy-deps.sdl2==0.4.5Kivy-Garden==0.1.5kivymd @ file:///C:/c/kivymd/KivyMDPillow==9.1.0Pygments==2.12.0pyperclip==1.8.2pypiwin32==223pywin32==303requests==2.27.1urllib3==1.26.9