A Python virtual environment keeps a Haystack project's packages separate from the system interpreter and from other Python projects. That isolation matters when a retrieval pipeline needs Haystack plus optional integrations, because each project can pin its own packages without changing global Python state.
Haystack is installed from the haystack-ai package, and Python's venv module creates the local .venv directory for the project. A POSIX shell on Linux or macOS uses .venv/bin/activate; on Ubuntu or Debian, install the python3-venv operating system package first if python3 -m venv is not available.
Keep the virtualenv inside the project directory and install packages with python -m pip after activation. After installation, python -m pip show haystack-ai should report a package location under .venv, and import haystack should run from the activated Python process.
Related: How to install Haystack with pip
Related: How to check the Haystack version
$ mkdir haystack-project
$ cd haystack-project
$ python3 --version Python 3.14.4
The current haystack-ai package requires Python 3.10 or newer. Use the newer interpreter explicitly if your system's default python3 points to an older release.
$ python3 -m venv .venv
The .venv directory belongs to this project. Do not commit it to version control; recreate it from package requirements on other machines.
$ source .venv/bin/activate
Your shell prompt may show (.venv) after activation.
$ python -m pip install --upgrade pip
Using python -m pip keeps the install tied to the activated Python interpreter instead of whichever pip executable appears first in the shell path.
$ python -m pip install haystack-ai
Optional integrations such as vector stores, model providers, or document converters are installed separately after the base haystack-ai package.
$ python -m pip show haystack-ai Name: haystack-ai Version: 2.30.2 ##### snipped ##### Location: /home/developer/haystack-project/.venv/lib/python3.14/site-packages ##### snipped #####
$ python -c "import haystack; print(haystack.__version__)" 2.30.2