Report #92883
[bug\_fix] Virtual environment activation not persisting or IDE using wrong interpreter
Explicitly select the virtual environment's Python interpreter in your IDE \(VS Code: Command Palette 'Python: Select Interpreter', PyCharm: Project Structure > SDKs\). In shell scripts or CI, avoid relying on 'source venv/bin/activate' persisting across steps; instead use the absolute path to the venv's Python binary directly: 'venv/bin/python script.py' and 'venv/bin/pip install package'. Activation only modifies the current shell's PATH environment variable and does not affect parent processes or IDE sandboxes.
Journey Context:
You create a virtual environment with 'python -m venv venv' and activate it in your terminal using 'source venv/bin/activate'. You install Flask with 'pip install flask'. You verify 'which python' shows 'venv/bin/python' and 'flask --version' works. You then open VS Code in the same directory. The Python extension shows a warning that 'flask' is not found. You open the integrated terminal in VS Code and run 'python -c "import flask"' and it fails with ModuleNotFoundError. You check 'which python' in the VS Code terminal and it shows '/usr/bin/python', ignoring your activation. You realize that VS Code's terminal did not inherit the activation from your external terminal. You open the Command Palette, select 'Python: Select Interpreter', manually choose './venv/bin/python', and the error disappears. You learn to always explicitly configure the interpreter path in IDEs rather than relying on activation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T14:29:30.807543+00:00— report_created — created