07-20-2022, 07:50 AM
How to Check ‘abc’ Package Version in Python?
5/5 – (2 votes)
In this article, I’ll show you:
How to check the version of the Python module (package, library) ? And how to check if is installed anyways?
These are the eight best ways to check the installed version of the Python module:
Before we go into these ways to check your version, let’s first quickly understand how versioning works in Python—you’ll be thankful to have spent a few seconds on this topic, believe me!
A Note on Python Version Numbering
Python versioning adds a unique identifier to different package versions using semantic versioning. Semantic versioning consists of three numerical units of versioning information in the format .
![[Image: versioning_py-1024x576.jpg]](https://blog.finxter.com/wp-content/uploads/2022/07/versioning_py-1024x576.jpg)
In this tutorial, we’ll use the shorthand general version abbreviation like so:
Practical examples would use numerical values for, , and :
This is shorthand for
Let’s dive into the meat of this article:
Question: How to check the (major, minor, patch) version of in your current Python environment?
Method 1: pip show
To check which version of the Python library is installed, run or in your CMD/Powershell (Windows), or terminal (macOS/Linux/Ubuntu).
This will work if your pip installation is version 1.3 or higher—which is likely to hold in your case because pip 1.3 was released a decade ago in 2013!!
Here’s an example in my Windows Powershell: I’ve highlighted the line that shows that my package version is:
In some instances, this will not work—depending on your environment. In this case, try those commands before giving up:
Next, we’ll dive into more ways to check your version.
![[Image: WillSmithMagnifyingGlassGIF.gif]](https://blog.finxter.com/wp-content/uploads/2022/07/WillSmithMagnifyingGlassGIF.gif)
But before we move on, I’m excited to present you my new Python book Python One-Liners (Amazon Link).
If you like one-liners, you’ll LOVE the book. It’ll teach you everything there is to know about a single line of Python code. But it’s also an introduction to computer science, data science, machine learning, and algorithms. The universe in a single line of Python!
![[Image: image-1.png]](https://blog.finxter.com/wp-content/uploads/2020/02/image-1.png)
The book was released in 2020 with the world-class programming book publisher NoStarch Press (San Francisco).
Link: https://nostarch.com/pythononeliners
Method 2: pip list
To check the versions of all installed packages, use and locate the version of in the output list of package versions sorted alphabetically.
This will work if your pip installation is version 1.3 or higher.
Here’s a simplified example for Windows Powershell, I’ve highlighted the line that shows the package version is:
In some instances, this will not work—depending on your environment. Then try those commands before giving up:
Method 3: pip list + findstr on Windows
To check the versions of a single package on Windows, you can chain with using the CMD or Powershell command: to locate the version of in the output list of package versions automatically.
Here’s an example for:
Method 4: Module __version__ Attribute
To check which version is installed of a given, you can use the attribute after importing the library (package, module) with .
Here’s the code:
Here’s an excerpt from the PEP 8 docs mentioning the attribute.
“PEP 8 describes the use of a module attribute called for recording “Subversion, CVS, or RCS” version strings using keyword expansion. In the PEP author’s own email archives, the earliest example of the use of an module attribute by independent module developers dates back to 1995.”
You can also use the following one-liner snippet to run this from your terminal (macOS, Linux, Ubuntu) or CMD/Powershell (Windows):
However, this method doesn’t work for all libraries, so while simple, I don’t recommend it as a general approach for that reason.
Method 5: importlib.metadata.version
The library provides a general way to check the package version in your Python script via for library . This returns a string representation of the specific version such as depending on the concrete version in your environment.
Here’s the code:
Method 6: conda list
If you have created your Python environment with Anaconda, you can use to list all packages installed in your (virtual) environment. Optionally, you can add a regular expression using the syntax to list only packages matching a certain pattern.
How to list all packages in the current environment?
How to list all packages installed into the environment?
Regex: How to list all packages starting with?
Method 7: pip freeze
The command without any option lists all installed Python packages in your environment in alphabetically order (ignoring UPPERCASE or lowercase). You can spot your specific package if it is installed in the environment.
Output example (depending on your concrete environment/installation):
You can modify or exclude specific packages using the options provided in this screenshot:
source
Method 8: pip freeze + grep on Linux/Ubuntu/macOS
To check the versions of a single package on Linux/Ubuntu/macOS, you can chain with using the CMD or Powershell command: to programmatically locate the version of your particular package in the output list of package versions.
Here’s an example for:
Related Questions
Check abc Installed Python
How to check if is installed in your Python script?
To check if is installed in your Python script, you can run in your Python shell and surround it by a try/except to catch a potential .
Check abc Version Python
How to check the package version of in Python?
To check which version of is installed, use or in your CMD/Powershell (Windows), or terminal (macOS/Linux/Ubuntu) to obtain the output .
Check abc Version Linux
How to check my version in Linux?
To check which version of is installed, use or in your Linux terminal.
Check abc Version Ubuntu
How to check my version in Ubuntu?
To check which version of is installed, use or in your Ubuntu terminal.
Check abc Version Windows
How to check my version on Windows?
To check which version of is installed, use or in your Windows CMD, command line, or PowerShell.
Check abc Version Mac
How to check my version on macOS?
To check which version of is installed, use or in your macOS terminal.
Check abc Version Jupyter Notebook
How to check my version in my Jupyter Notebook?
To check which version of is installed, add the line to your notebook cell where you want to check. Notice the exclamation mark prefix that allows you to run commands in your Python script cell.
Output: The following is an example on how this looks for in a Jupyter Notebook cell:
Check abc Version Conda/Anaconda
How to check the version in my conda installation?
Use to list version information about the specific package installed in your (virtual) environment.
Check abc Version with PIP
How to check the version with pip?
You can use multiple commands to check the version with PIP such as , , , and .
The former will output the specific version of. The remaining will output the version information of all installed packages and you have to locate first.
Check Package Version in VSCode or PyCharm
How to check the version in VSCode or PyCharm?
Integrated Development Environments (IDEs) such as VSCode or PyCharm provide a built-in terminal where you can run to check the current version of in the specific environment you’re running the command in.
You can type any of those commands in your IDE terminal like so:
![[Image: image-64-1024x560.png]](https://blog.finxter.com/wp-content/uploads/2022/07/image-64-1024x560.png)
Summary
In this article, you’ve learned those best ways to check a Python package version:
Thanks for giving us your valued attention — we’re grateful to have you here!![[Image: 1f642.png]](https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png)
Programmer Humor
There are only 10 kinds of people in this world: those who know binary and those who don’t.
![[Image: 1f469.png]](https://s.w.org/images/core/emoji/14.0.0/72x72/1f469.png)
![[Image: 1f9d4-200d-2642-fe0f.png]](https://s.w.org/images/core/emoji/14.0.0/72x72/1f9d4-200d-2642-fe0f.png)
~~~
There are 10 types of people in the world. Those who understand trinary, those who don’t, and those who mistake it for binary.
![[Image: 1f469.png]](https://s.w.org/images/core/emoji/14.0.0/72x72/1f469.png)
![[Image: 1f9d4-200d-2642-fe0f.png]](https://s.w.org/images/core/emoji/14.0.0/72x72/1f9d4-200d-2642-fe0f.png)
![[Image: 1f471-200d-2640-fe0f.png]](https://s.w.org/images/core/emoji/14.0.0/72x72/1f471-200d-2640-fe0f.png)
Related Tutorials
5/5 – (2 votes)
In this article, I’ll show you:
How to check the version of the Python module (package, library) Code:
abcCode:
abcThese are the eight best ways to check the installed version of the Python module
Code:
abc- Method 1: Code:
pip show abc
- Method 2: Code:
pip list
- Method 3: Code:
pip list | findstr abc
- Method 4: Code:
library.__version__
- Method 5: Code:
importlib.metadata.version
- Method 6: Code:
conda list
- Method 7: Code:
pip freeze
- Method 8: Code:
pip freeze | grep abc
Before we go into these ways to check your
Code:
abcA Note on Python Version Numbering
Python versioning adds a unique identifier to different package versions using semantic versioning. Semantic versioning consists of three numerical units of versioning information in the format Code:
major.minor.patch![[Image: versioning_py-1024x576.jpg]](https://blog.finxter.com/wp-content/uploads/2022/07/versioning_py-1024x576.jpg)
In this tutorial, we’ll use the shorthand general version abbreviation like so:
Code:
x.y.zPractical examples would use numerical values for
Code:
xCode:
yCode:
z- Code:
1.2.3
- Code:
4.1.4
- Code:
1.0.0
This is shorthand for
Code:
major.minor.patch- Major releases (toCode:
0.1.0) are used for the first stable release or “breaking changes”, i.e., major updates that break backward compatibility.Code:1.0.0
- Minor releases (toCode:
0.1.0) are used for larger bug fixes and new features that are backward compatible.Code:0.2.0
- Patch releases (toCode:
0.1.0) are used for smaller bug fixes that are backward compatible.Code:0.1.1
Let’s dive into the meat of this article:
Question: How to check the (major, minor, patch) version of Code:
abcMethod 1: pip show
To check which version of the Python library
Code:
abcCode:
pip show abcCode:
pip3 show abcThis will work if your pip installation is version 1.3 or higher—which is likely to hold in your case because pip 1.3 was released a decade ago in 2013!!
Here’s an example in my Windows Powershell: I’ve highlighted the line that shows that my package version is
Code:
a.b.cCode:
PS C:\Users\xcent> pip show abc
Name: abc
Version: a.b.c
Summary: ...
Home-page: ...
Author: ...
Author-email: ...
License: ...
Location: ...
Requires: ...
Required-by: ...In some instances, this will not work—depending on your environment. In this case, try those commands before giving up:
Code:
python -m pip show abc
python3 -m pip show abc
py -m pip show abc
pip3 show abcNext, we’ll dive into more ways to check your
Code:
abc![[Image: WillSmithMagnifyingGlassGIF.gif]](https://blog.finxter.com/wp-content/uploads/2022/07/WillSmithMagnifyingGlassGIF.gif)
But before we move on, I’m excited to present you my new Python book Python One-Liners (Amazon Link).
If you like one-liners, you’ll LOVE the book. It’ll teach you everything there is to know about a single line of Python code. But it’s also an introduction to computer science, data science, machine learning, and algorithms. The universe in a single line of Python!
![[Image: image-1.png]](https://blog.finxter.com/wp-content/uploads/2020/02/image-1.png)
The book was released in 2020 with the world-class programming book publisher NoStarch Press (San Francisco).
Link: https://nostarch.com/pythononeliners
Method 2: pip list
To check the versions of all installed packages, use
Code:
pip listCode:
abcThis will work if your pip installation is version 1.3 or higher.
Here’s a simplified example for Windows Powershell, I’ve highlighted the line that shows the package version is
Code:
1.2.3Code:
PS C:\Users\xcent> pip list
Package Version
--------------- ---------
aaa 1.2.3
...
abc 1.2.3
...
zzz 1.2.3In some instances, this will not work—depending on your environment. Then try those commands before giving up:
Code:
python -m pip list
python3 -m pip list
py -m pip list
pip3 listTo check the versions of a single package on Windows, you can chain
Code:
pip listCode:
findstr abcCode:
pip3 list | findstr abcCode:
abcHere’s an example for
Code:
abcCode:
pip3 list | findstr abc 1.2.3To check which version is installed of a given
Code:
libraryCode:
library.__version__Code:
import libraryHere’s the code:
Code:
import my_library
print(my_library.__version__)
# x.y.z for your version outputHere’s an excerpt from the PEP 8 docs mentioning the
Code:
__version__“PEP 8 describes the use of a module attribute called
Code:
__version__Code:
__version__You can also use the following one-liner snippet to run this from your terminal (macOS, Linux, Ubuntu) or CMD/Powershell (Windows):
Code:
python3 -c "import my_library; print(my_library.__version__)"However, this method doesn’t work for all libraries, so while simple, I don’t recommend it as a general approach for that reason.
Method 5: importlib.metadata.version
The
Code:
importlib.metadataCode:
importlib.metadata.version('abc')Code:
abcCode:
1.2.3Here’s the code:
Code:
import importlib.metadata
print(importlib.metadata.version('abc'))
# 1.2.3If you have created your Python environment with Anaconda, you can use
Code:
conda listCode:
conda list regexHow to list all packages in the current environment?
Code:
conda listHow to list all packages installed into the environment
Code:
'xyz'Code:
conda list -n xyzRegex: How to list all packages starting with
Code:
'abc'Code:
conda list '^abc'The
Code:
pip freezeCode:
abcCode:
pip freezeOutput example (depending on your concrete environment/installation):
Code:
PS C:\Users\xcent> pip freeze
aaa==1.2.3
...
abc==1.2.3
...
zzz==1.2.3You can modify or exclude specific packages using the options provided in this screenshot:
sourceMethod 8: pip freeze + grep on Linux/Ubuntu/macOS
To check the versions of a single package on Linux/Ubuntu/macOS, you can chain
Code:
pip freezeCode:
grep abcCode:
pip freeze | grep abcCode:
abcHere’s an example for
Code:
abcCode:
pip freeze | grep abc
abc==1.2.3Check abc Installed Python
How to check if
Code:
abcTo check if
Code:
abcCode:
import abcCode:
ModuleNotFoundErrorCode:
try: import abc print("Module abc installed")
except ModuleNotFoundError: print("Module abc not installed")How to check the package version of
Code:
abcTo check which version of
Code:
abcCode:
pip show abcCode:
pip3 show abcCode:
major.minor.patchCode:
pip show abc # or pip3 show abc
# 1.2.3How to check my
Code:
abcTo check which version of
Code:
abcCode:
pip show abcCode:
pip3 show abcCode:
pip show abc # or pip3 show abc
# 1.2.3How to check my
Code:
abcTo check which version of
Code:
abcCode:
pip show abcCode:
pip3 show abcCode:
pip show abc # or pip3 show abc
# 1.2.3How to check my
Code:
abcTo check which version of
Code:
abcCode:
pip show abcCode:
pip3 show abcCode:
pip show abc # or pip3 show abc
# 1.2.3How to check my
Code:
abcTo check which version of
Code:
abcCode:
pip show abcCode:
pip3 show abcCode:
pip show abc # or pip3 show abc
# 1.2.3How to check my
Code:
abcTo check which version of
Code:
abcCode:
!pip show abcCode:
!Code:
!pip show abcOutput: The following is an example on how this looks for
Code:
abcCode:
Package Version
--------------- ---------
aaa 1.2.3
...
abc 1.2.3
...
zzz 1.2.3How to check the
Code:
abcUse
Code:
conda list 'abc'Code:
conda list 'abc'How to check the
Code:
abcYou can use multiple commands to check the
Code:
abcCode:
pip show abcCode:
pip listCode:
pip freezeCode:
pip listCode:
pip show abc
pip list
pip freeze
pip listThe former will output the specific version of
Code:
abcCode:
abcCheck Package Version in VSCode or PyCharm
How to check the
Code:
abcIntegrated Development Environments (IDEs) such as VSCode or PyCharm provide a built-in terminal where you can run
Code:
pip show abcCode:
abcCode:
pip show abc
pip3 show abc pip list
pip3 list pip freeze
pip3 freezeYou can type any of those commands in your IDE terminal like so:
![[Image: image-64-1024x560.png]](https://blog.finxter.com/wp-content/uploads/2022/07/image-64-1024x560.png)
Summary
In this article, you’ve learned those best ways to check a Python package version:
- Method 1: Code:
pip show abc
- Method 2: Code:
pip list
- Method 3: Code:
pip list | findstr abc
- Method 4: Code:
library.__version__
- Method 5: Code:
importlib.metadata.version
- Method 6: Code:
conda list
- Method 7: Code:
pip freeze
- Method 8: Code:
pip freeze | grep abc
Thanks for giving us your valued attention — we’re grateful to have you here!
![[Image: 1f642.png]](https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png)
Programmer Humor
There are only 10 kinds of people in this world: those who know binary and those who don’t.
![[Image: 1f469.png]](https://s.w.org/images/core/emoji/14.0.0/72x72/1f469.png)
![[Image: 1f9d4-200d-2642-fe0f.png]](https://s.w.org/images/core/emoji/14.0.0/72x72/1f9d4-200d-2642-fe0f.png)
~~~
There are 10 types of people in the world. Those who understand trinary, those who don’t, and those who mistake it for binary.
![[Image: 1f469.png]](https://s.w.org/images/core/emoji/14.0.0/72x72/1f469.png)
![[Image: 1f9d4-200d-2642-fe0f.png]](https://s.w.org/images/core/emoji/14.0.0/72x72/1f9d4-200d-2642-fe0f.png)
![[Image: 1f471-200d-2640-fe0f.png]](https://s.w.org/images/core/emoji/14.0.0/72x72/1f471-200d-2640-fe0f.png)
Related Tutorials

