pylint-venv

raw JSON →
3.0.4 verified Fri May 01 auth: no python

pylint-venv provides a Pylint init-hook to automatically use the same Pylint installation with different virtual environments. Version 3.0.4 supports Python 3.7-3.13 and Pylint 3. It resolves virtual environment paths and configures the hook via pylintrc, pyproject.toml, or toml. Released as needed.

pip install pylint-venv
error ValueError: 'force_venv_activation' must be passed as a keyword argument
cause Using `inithook(True)` in pylint-venv 3.0+ where positional arguments are no longer allowed.
fix
Change to inithook(force_venv_activation=True).
error ModuleNotFoundError: No module named 'pylint_venv'
cause pylint-venv not installed in the environment where pylint runs, or wrong Python interpreter.
fix
Install pylint-venv in the same environment as pylint: pip install pylint-venv.
error pylint: error: argument --init-hook: invalid value: 'import pylint_venv; pylint_venv.inithook()'
cause The init-hook string in .pylintrc is not properly escaped or has syntax errors.
fix
Ensure the hook is on one line and does not contain quotes that break the config parser. Use: init-hook=import pylint_venv; pylint_venv.inithook()
breaking In v3.0.0, the `force_venv_activation` argument to `inithook` must be passed as a keyword argument. Positional usage breaks.
fix Use `inithook(force_venv_activation=True)` instead of `inithook(True)`.
gotcha The init-hook must be placed in the `[MAIN]` section of .pylintrc, not elsewhere like `[BASIC]`. Common mistake.
fix Ensure the line is under `[MAIN]` in your configuration file.
gotcha When using `pyproject.toml`, the hook must be configured via `[tool.pylint.MAIN]` section. People often put it under wrong tool table.
fix Place configuration under `[tool.pylint.MAIN]` in pyproject.toml.
deprecated Python 3.6 support was removed in v3.0.0. Using pylint-venv 3.x on Python 3.6 will fail.
fix Upgrade Python to 3.7+ or use pylint-venv 2.x.

Configure Pylint to automatically detect and use the virtual environment's packages.

# Add to your .pylintrc [MAIN] section:
# init-hook=import pylint_venv; pylint_venv.inithook()

# Or programmatically:
from pylint_venv import inithook
inithook()