Skip to content

Fix wrong Python executable path on Linux/macOS after creating conda environments#1459

Open
StellaHuang95 wants to merge 1 commit intomicrosoft:mainfrom
StellaHuang95:3-fix-wrong-python-exe-path-on-linux-macos
Open

Fix wrong Python executable path on Linux/macOS after creating conda environments#1459
StellaHuang95 wants to merge 1 commit intomicrosoft:mainfrom
StellaHuang95:3-fix-wrong-python-exe-path-on-linux-macos

Conversation

@StellaHuang95
Copy link
Copy Markdown
Contributor

Part of #1454

Bug

In createNamedCondaEnvironment and createPrefixCondaEnvironment, the Python executable path is computed as:

const bin = os.platform() === 'win32' ? 'python.exe' : 'python';
// Then: path.join(envPath, bin)

On Linux/macOS, this produces /path/to/env/python, but conda installs the Python executable at /path/to/env/bin/python.

Why it's a bug

The environment appears in the VS Code picker and can be selected. However, the internal execInfo.run.executable points to a non-existent path. Any operation that invokes Python — running scripts, linting, getting version info — fails silently. Users see a valid-looking conda environment that they can select, but nothing works after selecting it.

The quickCreateConda function (line 1225) already had the correct path:

os.platform() === 'win32' ? path.join(prefix, 'python.exe') : path.join(prefix, 'bin', 'python')

Repro steps

  1. On Linux or macOS, create a conda environment through the VS Code UI (either named or prefix type).
  2. The environment appears in the picker — select it.
  3. Try running a Python script or checking the Python version.
  4. Operations fail because the executable path /path/to/env/python does not exist.

Fix

Changed both createNamedCondaEnvironment (line 1085) and createPrefixCondaEnvironment (line 1169) to use:

const bin = os.platform() === 'win32' ? 'python.exe' : path.join('bin', 'python');

This matches the correct pattern already used in quickCreateConda.

Tests added

  • condaUtils.pythonExePath.unit.test.ts: 3 test cases verifying correct executable paths for both platform types and both environment types.

@StellaHuang95 StellaHuang95 added the bug Issue identified by VS Code Team member as probable bug label Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant