Microsoft/vscode
View on GitHubBetter integration of pre-commit hooks with Python virtual environments.
Open
#265,613 opened on Sep 8, 2025
feature-requestgithelp wanted
Description
Currently, pre-commit hooks inside VS Code cannot find tools installed in a project’s virtual environment unless VS Code itself is launched from within that environment.
Example
- I have a pre-commit hook configured to run
isort. - If I open the project directly in VS Code, pre-commit fails because
isortcannot be found. - If instead I activate the virtual environment in a terminal and then start VS Code with
code ., the environment is inherited correctly and pre-commit works.
This makes the workflow inconvenient since developers must remember to always launch VS Code from an activated venv.
Steps to Reproduce
- Create a Python project with a virtual environment.
- Install
isort(or another tool) in the venv. - Add a
.pre-commit-config.yamlwith a hook that uses the tool. - Open the project in VS Code without starting from the venv.
- Run a commit → pre-commit fails with tool not found.
Expected Behavior / Feature Proposal
It would be very useful if VS Code could automatically detect and use the project’s Python virtual environment when running pre-commit hooks.
This way, pre-commit would always work consistently regardless of how VS Code was launched.
Why This Matters
- Improves developer experience by reducing friction.
- Makes pre-commit integration more reliable for Python projects.
- Aligns with how VS Code already handles selecting Python interpreters for debugging and linting.