2025, Oct 18 05:00

Stop VS Code's Run Button from Using conda run: Restore Direct python.exe Calls by Disabling Python Environments

Fix VS Code's Run button launching conda run instead of the virtual environment's python.exe. Disable the Python Environments extension to restore direct runs.

When the Run button in VS Code starts launching Python with conda run instead of the interpreter from your virtual environment, it breaks established workflows and, in some shells, fails outright. The expected behavior is a direct call to the environment’s python.exe, but the button suddenly routes through conda, which can be unusable if the terminal session isn’t initialized for Conda or Miniforge.

Example of the unexpected command

Clicking the play button ends up running a conda wrapper rather than the interpreter path. In a PowerShell that isn’t initialized for Conda, this can result in output like the following:

(base) PS C:\Users\dev\Desktop\proj> & conda run --live-stream --name envBase python C:/Users/dev/Desktop/proj/app.py
usage: conda-script.py [-h] [-v] [--no-plugins] [-V] COMMAND ...
conda-script.py: error: argument COMMAND: invalid choice: '' (choose from activate, clean, commands, compare, config, create, deactivate, env, export, info, init, install, list, notices, package, doctor, repoquery, remove, uninstall, rename, run, search, update, upgrade)

The desired behavior is a direct call to the interpreter from the selected environment, similar to launching the script with the environment’s python.exe path without going through conda run.

What is actually happening

The confusion comes from assuming the play button is driven by Code Runner. In this scenario, the Run Python File action belongs to VS Code’s Python-related extension rather than the Code Runner extension. Adjusting Code Runner settings such as executorMap won’t affect Run Python File. This behavior, including the conda run indirection, has been reported and discussed in the Python extension’s issue tracker, which clarifies where the behavior originates.

References for context include the following reports in the Python extension repository: https://github.com/microsoft/vscode-python/issues/18634 and https://github.com/microsoft/vscode-python/issues/25335#issuecomment-3134925306.

Fix that restores direct Python invocation

The practical workaround is to disable the Python Environments extension. After disabling it, the Run button no longer forces execution through conda run. If necessary, restart VS Code so the change takes effect. With this adjustment, the run action aligns with the expectation of invoking the interpreter in the selected virtual environment directly.

Before and after at the command level

Problematic command routed through Conda:

& conda run --live-stream --name envBase python C:/Users/dev/Desktop/proj/app.py

Desired direct interpreter call from the active environment:

C:\path\to\current-env\python.exe C:\Users\dev\Desktop\proj\app.py

Why this matters for day-to-day work

Understanding which VS Code component owns the Run button prevents chasing the wrong settings. If your terminal isn’t a Conda-initialized shell, conda run will fail even though your environment and code are fine. Disabling Python Environments aligns the play button with a straightforward execution model and avoids shell-specific issues with Conda or Miniforge.

Conclusion

If the VS Code play button starts invoking conda run and breaks your workflow, don’t tweak Code Runner—target the right place. The Run Python File action comes from the Python extension, and disabling the Python Environments extension restores direct python.exe execution from the selected environment. If you prefer keeping Conda routing, you can continue to use a Conda-initialized terminal; otherwise, disabling that extension brings back the simpler and predictable invocation path.

The article is based on a question from StackOverflow by Zhang Xuan and an answer by Zhang Xuan.