# How to Find the Installed Pandas Version: 3 Reliable Methods

> Discover how to find your installed pandas version with 3 simple methods. Learn to check the version using pd.__version__, pd.show_versions(), or the internal _version_meson module.

- Repository: [pandas/pandas](https://github.com/pandas-dev/pandas)
- Tags: how-to-guide
- Published: 2026-02-16

---

**You can find the installed pandas version by accessing the `pd.__version__` attribute, calling `pd.show_versions()`, or importing `__git_version__` from the internal `_version_meson` module.**

When working with the `pandas-dev/pandas` repository or any project that depends on this data analysis library, knowing exactly which version is installed is critical for debugging, reproducibility, and compatibility checks. This guide explains how to find the installed pandas version using both public API methods and the underlying source code structure.

## Where Pandas Stores Version Information

Pandas exposes its version through a top-level attribute that is populated at import time. The actual version strings are generated during the build process by the **meson** build system, which replaced the older `versioneer` approach.

### The [`_version_meson.py`](https://github.com/pandas-dev/pandas/blob/main/_version_meson.py) Module

During the build process, the script defined in `meson.build` creates an autogenerated module named [`pandas/_version_meson.py`](https://github.com/pandas-dev/pandas/blob/main/pandas/_version_meson.py). This file contains two constants:

```python

# pandas/_version_meson.py (autogenerated during build)

__version__ = "2.2.2"          # example release

__git_version__ = "v2.2.2-0-gabcdef"

```

📄 **Source reference:** The generation logic is defined in [`meson.build` lines 48-53](https://github.com/pandas-dev/pandas/blob/main/meson.build#L48).

### The Package [`__init__.py`](https://github.com/pandas-dev/pandas/blob/main/__init__.py) Entry Point

The public `pandas` package imports these constants in its [`pandas/__init__.py`](https://github.com/pandas-dev/pandas/blob/main/pandas/__init__.py) file and re-exports them as part of the public API:

```python

# pandas/__init__.py (lines 176-180)

from pandas._version_meson import (  # pyright: ignore [reportMissingImports]

    __version__,
    __git_version__,
)

```

📄 **Source reference:** See the import in [[`pandas/__init__.py`](https://github.com/pandas-dev/pandas/blob/main/pandas/__init__.py) lines 176-180](https://github.com/pandas-dev/pandas/blob/main/pandas/__init__.py#L176).

## Three Methods to Find the Installed Pandas Version

Because the version constant is part of the public API, any code that imports pandas can retrieve it directly. Here are the three primary methods, ranging from simple attribute access to detailed diagnostic reports.

### Method 1: Access `pd.__version__` (Simplest)

The most common approach is to access the `__version__` attribute directly after importing pandas. This returns the semantic version string (e.g., `"2.2.2"`).

```python
import pandas as pd

print(pd.__version__)

# Output: 2.2.2

```

This method is ideal for quick checks in scripts or Jupyter notebooks where you need to verify compatibility before executing version-specific code.

### Method 2: Use `pd.show_versions()` (Detailed Report)

For debugging environment issues or submitting bug reports, pandas provides a utility function that prints a compact version summary together with the versions of its optional dependencies (NumPy, PyArrow, SQLAlchemy, etc.).

```python
import pandas as pd

pd.show_versions()

```

**Sample output:**

```

INSTALLED VERSIONS
------------------
commit           : 0f32a271c87b55c99b70376a545551f77601a5f8
python           : 3.11.0
pandas           : 2.2.2
numpy            : 1.26.0
pyarrow          : 15.0.0
...

```

📄 **Implementation details:** This function is implemented in [[`pandas/util/_print_versions.py`](https://github.com/pandas-dev/pandas/blob/main/pandas/util/_print_versions.py)](https://github.com/pandas-dev/pandas/blob/main/pandas/util/_print_versions.py), which imports `__git_version__` from the meson-generated module to display the exact git commit hash.

### Method 3: Access `__git_version__` (Git Reference)

In rare cases, you may need the exact git reference rather than the semantic version string. This is available by importing from the internal `_version_meson` module.

```python
from pandas._version_meson import __git_version__

print(__git_version__)

# Output: v2.2.2-0-gabcdef

```

**Note:** This method imports from a private module (`_version_meson`), so it is less stable than using `pd.__version__`. Use this only when you specifically need the git commit hash or detailed build information.

## How the Version is Generated During Build

Understanding the build process helps explain why these version attributes exist. Pandas uses the **meson** build system (as defined in `meson.build`) to generate version information at compile time rather than at runtime.

During the build, meson executes a script that creates [`pandas/_version_meson.py`](https://github.com/pandas-dev/pandas/blob/main/pandas/_version_meson.py) containing the `__version__` and `__git_version__` constants. This approach ensures that the version information is static and fast to access, requiring no runtime calculation or git repository access.

The generated file is then imported by [`pandas/__init__.py`](https://github.com/pandas-dev/pandas/blob/main/pandas/__init__.py), making the version immediately available to users upon `import pandas`.

## Summary

- **Use `pd.__version__`** for the standard semantic version string (e.g., `"2.2.2"`) in scripts and applications.
- **Use `pd.show_versions()`** to generate detailed environment reports including dependency versions for debugging.
- **Use `pandas._version_meson.__git_version__`** only when you need the exact git commit reference.
- The version constants are generated during the meson build process and stored in the autogenerated [`pandas/_version_meson.py`](https://github.com/pandas-dev/pandas/blob/main/pandas/_version_meson.py) file.

## Frequently Asked Questions

### How do I check pandas version in a script?

Import pandas and access the `__version__` attribute: `import pandas as pd; print(pd.__version__)`. This returns the installed version as a string (e.g., `"2.2.2"`), which you can use for conditional logic or logging.

### What is the difference between `__version__` and `__git_version__`?

`__version__` provides the semantic version string (e.g., `"2.2.2"`) suitable for compatibility checks, while `__git_version__` provides the exact git reference (e.g., `"v2.2.2-0-gabcdef"`) including the commit hash. The latter is useful for identifying specific development builds.

### Why does pandas use meson to generate version info?

Pandas uses the meson build system to generate [`pandas/_version_meson.py`](https://github.com/pandas-dev/pandas/blob/main/pandas/_version_meson.py) at compile time, replacing the older `versioneer` approach. This ensures version strings are static constants that load instantly at import time, rather than requiring runtime calculation or git repository access.

### How do I check pandas version from the command line?

You can check the version without opening a Python interpreter by running: `python -c "import pandas; print(pandas.__version__)"`. Alternatively, use `python -c "import pandas; pandas.show_versions()"` to see a full environment report including dependency versions.