Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tut] 8 Best Ways to Check the Package Version in Python

#1
8 Best Ways to Check the Package Version in Python

<div>
<div class="kk-star-ratings kksr-auto kksr-align-left kksr-valign-top" data-payload="{&quot;align&quot;:&quot;left&quot;,&quot;id&quot;:&quot;469309&quot;,&quot;slug&quot;:&quot;default&quot;,&quot;valign&quot;:&quot;top&quot;,&quot;reference&quot;:&quot;auto&quot;,&quot;class&quot;:&quot;&quot;,&quot;count&quot;:&quot;1&quot;,&quot;readonly&quot;:&quot;&quot;,&quot;score&quot;:&quot;5&quot;,&quot;best&quot;:&quot;5&quot;,&quot;gap&quot;:&quot;5&quot;,&quot;greet&quot;:&quot;Rate this post&quot;,&quot;legend&quot;:&quot;5\/5 - (1 vote)&quot;,&quot;size&quot;:&quot;24&quot;,&quot;width&quot;:&quot;142.5&quot;,&quot;_legend&quot;:&quot;{score}\/{best} - ({count} {votes})&quot;,&quot;font_factor&quot;:&quot;1.25&quot;}">
<div class="kksr-stars">
<div class="kksr-stars-inactive">
<div class="kksr-star" data-star="1" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="2" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="3" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="4" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" data-star="5" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
</p></div>
<div class="kksr-stars-active" style="width: 142.5px;">
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
<div class="kksr-star" style="padding-right: 5px">
<div class="kksr-icon" style="width: 24px; height: 24px;"></div>
</p></div>
</p></div>
</div>
<div class="kksr-legend" style="font-size: 19.2px;"> 5/5 – (1 vote) </div>
</div>
<p>In this article, I’ll show you how to check the version of a <a href="https://blog.finxter.com/how-to-write-a-python-module-package/" data-type="post" data-id="35371" target="_blank" rel="noreferrer noopener">Python module</a> (package, library).</p>
<p>These are the eight best ways to check the version of a Python module:</p>
<ul class="has-global-color-8-background-color has-background">
<li><strong>Method 1</strong>: <code>pip show my_package</code></li>
<li><strong>Method 2</strong>: <code>pip list</code></li>
<li><strong>Method 3</strong>: <code>pip list | findstr my_package</code></li>
<li><strong>Method 4</strong>: <code>my_package.__version__</code></li>
<li><strong>Method 5</strong>: <code>importlib.metadata.version</code></li>
<li><strong>Method 6</strong>: <code>conda list</code></li>
<li><strong>Method 7</strong>: <code>pip freeze</code></li>
<li><strong>Method 8</strong>: <code>pip freeze | grep my_package</code></li>
</ul>
<p>Let’s dive into some examples for each of those next!</p>
<h2>Method 1: pip show</h2>
<p class="has-pale-cyan-blue-background-color has-background">To check which version of a given Python library, say <code>xyz</code>, is installed, use <code><a rel="noreferrer noopener" href="https://blog.finxter.com/a-guide-of-all-pip-commands/" data-type="post" data-id="90570" target="_blank">pip show xyz</a></code> or <code>pip3 show xyz</code>. For example, to check the version of your <a title="NumPy Tutorial – Everything You Need to Know to Get Started" rel="noreferrer noopener" href="https://blog.finxter.com/numpy-tutorial/" target="_blank">NumPy </a>installation, run <code>pip show numpy</code> in your CMD/Powershell (Windows), or terminal (macOS/Linux/Ubuntu). </p>
<p>This will work if your <a href="https://blog.finxter.com/installing-specific-package-versions-with-pip/" data-type="post" data-id="320873" target="_blank" rel="noreferrer noopener">pip</a> installation is version <a rel="noreferrer noopener" title="https://github.com/pypa/pip/blob/1.3/CHANGES.txt#L54" href="https://github.com/pypa/pip/blob/1.3/CHANGES.txt#L54" target="_blank">1.3</a> or higher—which is likely to hold in your case because pip 1.3 was released a decade ago in 2013!! </p>
<p>Here’s an example in my Windows <a rel="noreferrer noopener" href="https://blog.finxter.com/powershell-operators/" data-type="post" data-id="79052" target="_blank">Powershell</a> for NumPy: I’ve highlighted the line that shows that my package version is <code>1.21.0</code>:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="powershell" data-enlighter-theme="" data-enlighter-highlight="1, 3" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">PS C:\Users\xcent> pip show numpy
Name: numpy
Version: 1.21.0
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location: c:\users\xcent\appdata\local\programs\python\python39\lib\site-packages
Requires:
Required-by: pandas, matplotlib</pre>
<p>In some instances, this will not work—depending on your environment. In this case, try those commands before giving up:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="powershell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">python -m pip show numpy
python3 -m pip show numpy
py -m pip show numpy
pip3 show numpy</pre>
<p>Of course, replace “<code>numpy</code>” with your particular package name.</p>
<h2>Method 2: pip list</h2>
<p class="has-pale-cyan-blue-background-color has-background">To check the versions of <strong><em>all</em></strong> installed packages, use <code><a rel="noreferrer noopener" title="https://pip.pypa.io/en/stable/cli/pip_show/" href="https://pip.pypa.io/en/stable/cli/pip_show/" target="_blank">pip list</a></code> and locate the version of your particular package in the output list of package versions sorted alphabetically.</p>
<p>This will work if your pip installation is version <a href="https://github.com/pypa/pip/blob/1.3/CHANGES.txt#L54" target="_blank" rel="noreferrer noopener" title="https://github.com/pypa/pip/blob/1.3/CHANGES.txt#L54">1.3</a> or higher.</p>
<p>Here’s an example in my Windows Powershell, I’ve highlighted the line that shows that my package version is 1.21.0:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="powershell" data-enlighter-theme="" data-enlighter-highlight="1" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">PS C:\Users\xcent> pip list
Package Version
--------------- ---------
beautifulsoup4 4.9.3
bs4 0.0.1
certifi 2021.5.30
chardet 4.0.0
cycler 0.10.0
idna 2.10
kiwisolver 1.3.1
matplotlib 3.4.2
mss 6.1.0
numpy 1.21.0
pandas 1.3.1
Pillow 8.3.0
pip 21.1.1
pyparsing 2.4.7
python-dateutil 2.8.1
pytz 2021.1
requests 2.25.1
setuptools 56.0.0
six 1.16.0
soupsieve 2.2.1
urllib3 1.26.6</pre>
<p>In some instances, this will not work—depending on your environment. Then try those commands before giving up:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="powershell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">python -m pip list
python3 -m pip list
py -m pip list
pip3 list </pre>
<h2>Method 3: pip list + findstr on Windows</h2>
<p class="has-global-color-8-background-color has-background">To check the versions of <strong><em>a single package </em>on Windows</strong>, you can chain <code><a rel="noreferrer noopener" title="https://pip.pypa.io/en/stable/cli/pip_show/" href="https://pip.pypa.io/en/stable/cli/pip_show/" target="_blank">pip list</a></code> with <code>findstr xyz</code> using the CMD or Powershell command: <code>pip3 list | findstr numpy</code> to locate the version of your particular package <code>xyz</code> in the output list of package versions automatically.</p>
<p>Here’s an example for <code>numpy</code>:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip3 list | findstr numpy 1.21.0</pre>
<h2>Method 4: Library.__version__ Attribute</h2>
<p class="has-pale-cyan-blue-background-color has-background">To check your package installation in your Python script, you can also use the <code>xyz.__version__</code> attribute of the particular library <code>xyz</code>. Not all packages provide this attribute but as it is recommended by <a href="https://peps.python.org/pep-0008/#module-level-dunder-names" data-type="URL" data-id="https://peps.python.org/pep-0008/#module-level-dunder-names" target="_blank" rel="noreferrer noopener">PEP</a>, it’ll work for most libraries.</p>
<p>Here’s the code:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="2" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import numpy
print(numpy.__version__)
# 1.21.0</pre>
<p>Here’s an excerpt from the <a rel="noreferrer noopener" href="https://peps.python.org/pep-0396/" data-type="URL" data-id="https://peps.python.org/pep-0396/" target="_blank">PEP 8 docs</a> mentioning the <code>__version__</code> attribute. </p>
<p class="has-base-2-background-color has-background"><em>“<a href="https://peps.python.org/pep-0008">PEP 8</a> describes the use of a module attribute called <code>__version__</code> 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 <code>__version__</code> module attribute by independent module developers dates back to 1995.”</em></p>
<h2>Method 5: importlib.metadata.version</h2>
<p class="has-pale-cyan-blue-background-color has-background">The <code>importlib.metadata</code> library provides a general way to check the package version in your Python script via <code><a rel="noreferrer noopener" title="https://docs.python.org/3/library/importlib.metadata.html#distribution-versions" href="https://docs.python.org/3/library/importlib.metadata.html#distribution-versions" target="_blank">importlib.metadata.version('xyz')</a></code> for library <code>xyz</code>. This returns a string representation of the specific version. For example, <code>importlib.metadata.version('numpy')</code> returns <code>1.21.0</code> in my current environment.</p>
<p>Here’s the code:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="2" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">import importlib.metadata
print(importlib.metadata.version('numpy'))
# 1.21.0</pre>
<h2>Method 6: conda list</h2>
<p class="has-global-color-8-background-color has-background">If you have created your Python environment with Anaconda, you can use <code><a rel="noreferrer noopener" href="https://docs.conda.io/projects/conda/en/latest/commands/list.html" data-type="URL" data-id="https://docs.conda.io/projects/conda/en/latest/commands/list.html" target="_blank">conda list</a></code> to list all packages installed in your (virtual) environment. Optionally, you can add a regular expression using the syntax conda list regex to list only packages matching a certain pattern.</p>
<p>How to list all packages in the current environment?</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">conda list</pre>
<p>How to list all packages installed into the environment <code>'xyz'</code>?</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">conda list -n xyz</pre>
<p><strong><a href="https://blog.finxter.com/python-regex/" data-type="post" data-id="6210" target="_blank" rel="noreferrer noopener">Regex</a></strong>: How to list all packages starting with <code>'py'</code>?</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">conda list '^py'</pre>
<p><strong><a rel="noreferrer noopener" href="https://blog.finxter.com/python-regex/" data-type="post" data-id="6210" target="_blank">Regex</a></strong>: How to list all packages starting with <code>'py'</code> or <code>'code'</code>?</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">conda list '^(py|code)'</pre>
<h2>Method 7: pip freeze</h2>
<p>The <code>pip freeze</code> 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. </p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip freeze</pre>
<p><strong>Output</strong> from my local Windows environment with PowerShell (strange packages I know) Wink:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">PS C:\Users\xcent> pip freeze
asn1crypto==1.5.1
et-xmlfile==1.1.0
openpyxl==3.0.10</pre>
<p>For example, I have the Python package <code><a href="https://blog.finxter.com/how-to-install-openpyxl-in-python/" data-type="post" data-id="457066">openpyxl</a></code> installed with version <code>3.0.10</code>. </p>
<hr class="wp-block-separator has-alpha-channel-opacity"/>
<div class="wp-block-comments-query-loop"></div>
<p>You can modify or exclude specific packages using the options provided in this screenshot:</p>
<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" width="783" height="938" src="https://blog.finxter.com/wp-content/uploads/2022/07/image-62.png" alt="" class="wp-image-469381" srcset="https://blog.finxter.com/wp-content/uploads/2022/07/image-62.png 783w, https://blog.finxter.com/wp-content/uplo...50x300.png 250w, https://blog.finxter.com/wp-content/uplo...68x920.png 768w" sizes="(max-width: 783px) 100vw, 783px" /><figcaption><a href="https://pip.pypa.io/en/stable/cli/pip_freeze/" data-type="URL" data-id="https://pip.pypa.io/en/stable/cli/pip_freeze/" target="_blank" rel="noreferrer noopener">source</a></figcaption></figure>
</div>
<h2>Method 8: pip freeze + grep on Linux/Ubuntu/macOS</h2>
<p class="has-global-color-8-background-color has-background">To check the versions of <strong><em>a single package </em>on Linux/Ubuntu/macOS</strong>, you can chain <code>pip freeze</code> with <code>grep xyz</code> using the CMD or Powershell command: <code>pip freeze | grep xyz</code> to programmatically locate the version of your particular package <code>xyz</code> in the output list of package versions.</p>
<p>Here’s an example for <code>numpy</code>:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip freeze | grep scikit-learn
scikit-learn==0.17.1</pre>
<h2>Related Questions</h2>
<h3>Check Package Version Python</h3>
<p><strong>How to check package version in Python?</strong></p>
<p class="has-global-color-8-background-color has-background">To check which version of a given Python package is installed, use <code>pip show my_package</code>. For example, to check the version of your <a title="NumPy Tutorial – Everything You Need to Know to Get Started" rel="noreferrer noopener" href="https://blog.finxter.com/numpy-tutorial/" target="_blank">NumPy </a>installation, run <code>pip show numpy</code> in your CMD/Powershell (Windows), or terminal (macOS/Linux/Ubuntu). </p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip show my_package</pre>
<h3>Check Package Version Linux</h3>
<p><strong>How to check my package version in Linux?</strong></p>
<p class="has-global-color-8-background-color has-background">To check which version of a given Python package is installed, use <code>pip show my_package</code>. For example, to check the version of your <a title="NumPy Tutorial – Everything You Need to Know to Get Started" rel="noreferrer noopener" href="https://blog.finxter.com/numpy-tutorial/" target="_blank">NumPy </a>installation, run <code>pip show numpy</code> in your Linux terminal.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip show my_package</pre>
<h3>Check Package Version Ubuntu</h3>
<p><strong>How to check my package version in Ubuntu?</strong></p>
<p class="has-global-color-8-background-color has-background">To check which version of a given Python package is installed, use <code>pip show my_package</code>. For example, to check the version of your <a title="NumPy Tutorial – Everything You Need to Know to Get Started" rel="noreferrer noopener" href="https://blog.finxter.com/numpy-tutorial/" target="_blank">NumPy </a>installation, run <code>pip show numpy</code> in your Ubuntu terminal/shall/bash.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip show my_package</pre>
<h3>Check Package Version Windows</h3>
<p><strong>How to check package version on Windows?</strong></p>
<p class="has-global-color-8-background-color has-background">To check which version of a given Python package is installed, use <code>pip show my_package</code>. For example, to check the version of your <a title="NumPy Tutorial – Everything You Need to Know to Get Started" rel="noreferrer noopener" href="https://blog.finxter.com/numpy-tutorial/" target="_blank">NumPy </a>installation, run <code>pip show numpy</code> in your Windows CMD, command line, or PowerShell.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip show my_package</pre>
<h3>Check Package Version Mac</h3>
<p><strong>How to check package version on macOS?</strong></p>
<p class="has-global-color-8-background-color has-background">To check which version of a given Python package is installed, use <code>pip show my_package</code>. For example, to check the version of your <a title="NumPy Tutorial – Everything You Need to Know to Get Started" rel="noreferrer noopener" href="https://blog.finxter.com/numpy-tutorial/" target="_blank">NumPy </a>installation, run <code>pip show numpy</code> in your macOS terminal.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip show my_package</pre>
<h3>Check Package Version Jupyter Notebook</h3>
<p><strong>How to check package version in your Jupyter Notebook?</strong></p>
<p class="has-global-color-8-background-color has-background">To check which version of a given Python package is installed, add the line <code>!pip show my_package</code> to your notebook cell where you want to check. Notice the exclamation mark prefix <code>!</code> that allows you to run commands in your Python script cell. For example, to check the version of your <a title="NumPy Tutorial – Everything You Need to Know to Get Started" rel="noreferrer noopener" href="https://blog.finxter.com/numpy-tutorial/" target="_blank">NumPy </a>installation, run <code>!pip show numpy</code> in your macOS terminal.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">!pip show my_package</pre>
<p>For example, this is a screenshot on how this looks for numpy in a Jupyter Notebook:</p>
<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" width="1024" height="264" src="https://blog.finxter.com/wp-content/uploads/2022/07/image-63-1024x264.png" alt="" class="wp-image-469475" srcset="https://blog.finxter.com/wp-content/uploads/2022/07/image-63-1024x264.png 1024w, https://blog.finxter.com/wp-content/uplo...300x77.png 300w, https://blog.finxter.com/wp-content/uplo...68x198.png 768w, https://blog.finxter.com/wp-content/uplo...age-63.png 1076w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>
<h3>Check Package Version Terminal</h3>
<p><strong>How to check package version in my terminal?</strong></p>
<p class="has-global-color-8-background-color has-background">To check which version of a given Python package is installed, use <code>pip show my_package</code>. For example, to check the version of your <a title="NumPy Tutorial – Everything You Need to Know to Get Started" rel="noreferrer noopener" href="https://blog.finxter.com/numpy-tutorial/" target="_blank">NumPy </a>installation, run <code>pip show numpy</code> in your terminal.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip show my_package</pre>
<h3>Check Package Version Conda/Anaconda</h3>
<p><strong>How to check package version in my conda installation?</strong></p>
<p class="has-global-color-8-background-color has-background">Use <code>conda list 'my_package'</code> to list version information about the specific package installed in your (virtual) environment.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">conda list 'my_package'</pre>
<h3>Check Package Version with PIP</h3>
<p><strong>How to check package version with pip?</strong></p>
<p class="has-global-color-8-background-color has-background">You can use multiple commands to check the package version with PIP such as <code>pip show my_package</code>, <code>pip list</code>, <code>pip freeze</code>, and <code>pip list</code>. </p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip show my_package
pip list
pip freeze
pip list</pre>
<h3>Check Package Version in VSCode or PyCharm</h3>
<p><strong>How to check package version in VSCode or PyCharm?</strong></p>
<p class="has-global-color-8-background-color has-background">Integrated Development Environments (IDEs) such as VSCode or PyCharm provide a built-in terminal where you can run <code>pip show my_package</code> to check the current version of <code>my_package</code> in the specific environment you’re running the command in.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip show my_package
pip list
pip freeze</pre>
<p>You can type any of those commands in your IDE terminal like so:</p>
<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" width="1024" height="560" src="https://blog.finxter.com/wp-content/uploads/2022/07/image-64-1024x560.png" alt="pip IDE check package version" class="wp-image-469483" srcset="https://blog.finxter.com/wp-content/uploads/2022/07/image-64-1024x560.png 1024w, https://blog.finxter.com/wp-content/uplo...00x164.png 300w, https://blog.finxter.com/wp-content/uplo...68x420.png 768w, https://blog.finxter.com/wp-content/uplo...36x840.png 1536w, https://blog.finxter.com/wp-content/uplo...age-64.png 1924w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>
<h2>Summary</h2>
<p>In this article, you’ve learned those best ways to check a Python package version:</p>
<ul>
<li><strong>Method 1</strong>: <code>pip show my_package</code></li>
<li><strong>Method 2</strong>: <code>pip list</code></li>
<li><strong>Method 3</strong>: <code>pip list | findstr my_package</code></li>
<li><strong>Method 4</strong>: <code>my_package.__version__</code></li>
<li><strong>Method 5</strong>: <code>importlib.metadata.version</code></li>
<li><strong>Method 6</strong>: <code>conda list</code></li>
<li><strong>Method 7</strong>: <code>pip freeze</code></li>
<li><strong>Method 8</strong>: <code>pip freeze | grep my_package</code></li>
</ul>
<p>Thanks for giving us your valued attention — we’re grateful to have you here! <img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f642.png" alt="?" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<hr class="wp-block-separator has-alpha-channel-opacity"/>
<h2>Programmer Humor</h2>
<p class="has-global-color-8-background-color has-background"><em>There are only 10 kinds of people in this world: those who know binary and those who don’t.<br /></em><img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f469.png" alt="?" class="wp-smiley" style="height: 1em; max-height: 1em;" /><img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f9d4-200d-2642-fe0f.png" alt="?‍♂️" class="wp-smiley" style="height: 1em; max-height: 1em;" /><em><br />~~~</p>
<p>There are 10 types of people in the world. Those who understand trinary, those who don’t, and those who mistake it for binary.</em> <em><br /></em><img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f469.png" alt="?" class="wp-smiley" style="height: 1em; max-height: 1em;" /><img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f9d4-200d-2642-fe0f.png" alt="?‍♂️" class="wp-smiley" style="height: 1em; max-height: 1em;" /><img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f471-200d-2640-fe0f.png" alt="?‍♀️" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
</div>


https://www.sickgaming.net/blog/2022/07/...in-python/
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016