You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clicking the Run Python File button in a Conda environment with Git Bash fails, because it uses backslashes in the environment path which Git Bash treats as escape characters. Solution is to use forward slashes or wrap the path in quotes.
Steps to reproduce:
Use Git Bash as the default shell for VS Code's integrated terminal
Open a project and create a Conda environment in the project root (conda create -p "./cenv")
Select the Conda environment as the workspace interpreter (F1 -> Python: Select Interpreter)
Click the Run Python File button in the top right
It tries running conda activate C:\path\to\cenv and fails
Adam@Adam-PC MINGW64 /c/_MyFiles/Programming/Sandbox/example
$ source activate
(base)
Adam@Adam-PC MINGW64 /c/_MyFiles/Programming/Sandbox/example
$ conda activate C:\_MyFiles\Programming\Sandbox\clip\cenv
EnvironmentNameNotFound: Could not find conda environment: C:_MyFilesProgrammingSandboxclipcenv
You can list all discoverable environments with `conda info --envs`.
(base)
Adam@Adam-PC MINGW64 /c/_MyFiles/Programming/Sandbox/example
$ cd c:/_MyFiles/Programming/Sandbox/example
(base)
Adam@Adam-PC MINGW64 /c/_MyFiles/Programming/Sandbox/example
$ C:/_MyFiles/Programming/Sandbox/clip/cenv/python.exe c:/_MyFiles/Programming/Sandbox/example/main.py
(base)
Adam@Adam-PC MINGW64 /c/_MyFiles/Programming/Sandbox/example
$
Diagnostic data
Python version (& distribution if applicable, e.g. Anaconda): 3.8.18
Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
Value of the python.languageServer setting: Default
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
@adamerose , Python extension does not support Git bash currently, and such an issue was recently closed because of lack of community interest: #15799 as well as significant technical blockers which can only be resolved by VS Code: #15799 (comment).
Clicking Run Python File seems to work fine with Git Bash + venv:
It just behaves differently for conda. Can't the extension use forward slashes for conda like it does for venv? The upstream issue you linked is about an Extension API for escaping backslashes but I don't think that is the only solution
While it's true that using forward slashes might be a suitable workaround for conda, it might not. Supporting git bash results in other complications hence we cannot simply officially support it at this point.
That being said, if you can contribute a fix and demonstrate to us that it works, we'll be happy to accept it.
Type: Bug
Clicking the
Run Python File
button in a Conda environment with Git Bash fails, because it uses backslashes in the environment path which Git Bash treats as escape characters. Solution is to use forward slashes or wrap the path in quotes.Steps to reproduce:
conda create -p "./cenv"
)Python: Select Interpreter
)conda activate C:\path\to\cenv
and failsDiagnostic data
python.languageServer
setting: DefaultOutput for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)User Settings
Extension version: 2023.20.0
VS Code version: Code 1.84.0 (d037ac076cee195194f93ce6fe2bdfe2969cc82d, 2023-11-01T11:29:04.398Z)
OS version: Windows_NT x64 10.0.22621
Modes:
System Info
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
A/B Experiments
The text was updated successfully, but these errors were encountered: