Python projects can use separate package environments. pandas should be installed with pip from the same Python environment that will import it.

A virtual environment keeps pandas and its dependencies under the project .venv directory instead of the system Python installation on Linux, macOS, and Windows. A working Python 3 installation with pip and venv is required; the pandas developers distribute the package through PyPI.

The install is complete only when the same interpreter can import pandas and run a small DataFrame operation. Optional extras such as pandas[excel] belong to follow-up file I/O tasks; the base install is enough for in-memory DataFrame work and CSV tasks.

Steps to install pandas with pip:

  1. Create a virtual environment in the pandas project directory.
    $ python3 -m venv .venv

    On Windows, use Command Prompt with py -m venv .venv instead. The venv module creates a private environment from the selected Python installation.

  2. Activate the virtual environment.
    $ source .venv/bin/activate
    (.venv) $

    On Windows Command Prompt, use .venv\Scripts\activate.bat instead. Activation puts the environment's Python on PATH, so python is used for every remaining command on all three platforms.

  3. Confirm that pip belongs to the active environment.
    (.venv) $ python -m pip --version
    pip 26.2.2 from /home/user/project/.venv/lib/python3.15/site-packages/pip (python 3.15)

    The path should include .venv or the environment name. The directory separators differ on Windows. If it points to a system path, reactivate the environment before installing pandas.

  4. Upgrade pip inside the active environment.
    (.venv) $ python -m pip install --upgrade pip
    Requirement already satisfied: pip in ./.venv/lib/python3.15/site-packages (26.2.2)
    ##### snipped #####
    Successfully installed pip-26.3
  5. Install pandas from PyPI.
    (.venv) $ python -m pip install pandas
    Collecting pandas
    ##### snipped #####
    Successfully installed numpy-2.5.4 pandas-3.1.1 python-dateutil-4.0.0 tzdata-2026.6

    pip installs required runtime packages such as NumPy and python-dateutil with pandas. The exact versions and dependency list depend on the platform and release. Add optional extras later only when a task needs them, such as pandas[excel] for Excel I/O.

  6. Verify that the active environment can import pandas and construct a DataFrame.
    (.venv) $ python -c "import pandas as pd; print(pd.__version__); print(pd.DataFrame({'name': ['Ada', 'Lin'], 'score': [95, 88]}))"
    3.1.1
      name  score
    0  Ada     95
    1  Lin     88

    A version line plus a printed DataFrame confirms that the package imports and basic tabular construction works in the active environment.
    Related: How to create a pandas DataFrame

Share this guide