

In this article, we’ve studied four ways to check the package version using pip: For example, ('numpy') returns the version 1.21.0 in my current Windows environment. Calling it will return a string representation of the specific version. # 1.21.0 Method 4: Ī more general way to check the package version in your Python script is provided by the tadata package in the form of a version(your_package_name_string) function. However, it is not required for Python packages to provide the _version_ attribute, so it’s not 100% reliable. This will print the package version for most packages. PS C:\Users\xcent> py -m pip list Method 3: Check Package Version in Your Python ScriptĪn alternative is to check your package installation in your Python script by first importing the library with import your_package and then call print(your_package._version_). Then try those commands before giving up: PS C:\Users\xcent> python -m pip list In some instances, this will not work-depending on your environment. Here’s an example in my Windows Powershell, I’ve highlighted the line that shows that my package version is 1.21.0: PS C:\Users\xcent> pip list This will work if your pip installation is version 1.3 or higher. The fact that the output packages are sorted alphabetically may find to locate the particular package. You can then locate the version of your particular package in the resulting output. To check the versions of all installed packages, use the pip list command. Of course, replace “ numpy” with your particular package name.


PS C:\Users\xcent> python3 -m pip show numpy In this case, try those commands before giving up: PS C:\Users\xcent> python -m pip show numpy Location: c:\users\xcent\appdata\local\programs\python\python39\lib\site-packages Summary: NumPy is the fundamental package for array computing with Python. Here’s an example in my Windows Powershell, I’ve highlighted the line that shows that my package version is 1.21.0: PS C:\Users\xcent> pip show numpy 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!! For example, to check the version of your NumPy installation or virtual environment, run pip show numpy in your command line or Powershell (Windows), or terminal (macOS and Linux/Ubuntu). To check which version of a given package is installed, use the pip show command. How to check the version of a package with pip? Method 1: pip show Assuming you have the Python package manager pip installed in your operating system (Windows, Linux, macOS).
