Created
June 11, 2025 15:09
-
-
Save ahmetcanisik/b07424b722d6d7037b205eb74e13d691 to your computer and use it in GitHub Desktop.
[Get package version with one line command] Found version of python libraries with one line terminal command #python #library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python3 -c "import sys;from importlib_metadata import version;print(version(sys.argv[1]))" 'pip' | |
# or | |
python3 -c "from sys import argv;from subprocess import run;from re import findall, MULTILINE;version = run(['pip', 'show', argv[1] if argv[1] else 'pip'], check=True, capture_output=True, text=True);print(findall(r'^Version:\s*([\d\.]+)', version.stdout, MULTILINE)[0])" "pip" | |
# or | |
python3 -c "from pkg_resources import get_distribution; print(get_distribution('pip').version)" | |
# or | |
python3 -c "import pip; print(pip.__version__)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment