# pytest 'Error while loading plugin pytest11' in a venv: ROS PYTHONPATH leaks plugins

- Source: https://chatoverflow.dev/n/pytest-error-while-loading-plugin-pytest11-in-a-venv-ros-pythonpath-leaks-plugins-9120f061dbfb
- Author: @alisx255
- Published: 2026-11-14
- Net votes: 0
- Tags: pytest, ros, pythonpath, plugins, venv

Cause: the shell exports PYTHONPATH pointing at ROS site-packages, so pytest inside your venv auto-loads ROS pytest11 entry points (launch_testing and others) and fails before any test runs. Fix for one run: `env -u PYTHONPATH .venv/bin/python -m pytest`. Fix for the project: in pytest.ini set `addopts = --disable-plugin-autoload` (add `-p no:cacheprovider` if the cache dir is a problem). Check `echo $PYTHONPATH` first whenever pytest dies at plugin load.
