Skip to content

Failed to load plugins when create a virtualenv with --system-site-packages #13637

@msclock

Description

@msclock
  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

When a virtual environment is created with --system-site-packages, pytest fails to load plugins.

minimal reproducible steps:

virtualenv .venv --system-site-packages
source .venv/bin/activate
pip install pytest pytest-benchmark
pytest --fixtures | grep benchmark || echo $?
created virtual environment CPython3.10.12.final.0-64 in 1918ms
  creator CPython3Posix(dest=/home/fengli/test/.venv, clear=False, no_vcs_ignore=False, global=True)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, via=copy, app_data_dir=/home/fengli/.local/share/virtualenv)
    added seed packages: pip==25.1.1, setuptools==80.9.0
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Looking in indexes: https://nexus.infra.agibot.com/repository/pypi-proxy/simple, https://nexus.infra.agibot.com/repository/pypi/simple
Requirement already satisfied: pytest in /home/fengli/.local/lib/python3.10/site-packages (8.1.1)
Collecting pytest-benchmark
  Downloading https://nexus.infra.agibot.com/repository/pypi-proxy/packages/pytest-benchmark/5.1.0/pytest_benchmark-5.1.0-py3-none-any.whl (44 kB)
Requirement already satisfied: iniconfig in /usr/local/lib/python3.10/dist-packages (from pytest) (2.0.0)
Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from pytest) (23.2)
Requirement already satisfied: pluggy<2.0,>=1.4 in /usr/local/lib/python3.10/dist-packages (from pytest) (1.5.0)
Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /usr/local/lib/python3.10/dist-packages (from pytest) (1.2.2)
Requirement already satisfied: tomli>=1 in /home/fengli/.local/lib/python3.10/site-packages (from pytest) (2.0.2)
Requirement already satisfied: py-cpuinfo in /usr/local/lib/python3.10/dist-packages (from pytest-benchmark) (9.0.0)
Installing collected packages: pytest-benchmark
Successfully installed pytest-benchmark-5.1.0

[notice] A new release of pip is available: 25.1.1 -> 25.2
[notice] To update, run: pip install --upgrade pip
1

It reports no benchmark marks in the output.

Pytest seems to use python path to load plugins only. It works fine with --system-site-packages when plugins are pre-installed in systems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions