Skip to content

Specifying the Python interpreter in launch.json using the CONDA_PREFIX environment variable raises an error #158

@FSpanhel

Description

@FSpanhel

Type: Bug

The following configuration launch.json sets the Python interpreter to the Python interpreter of the activated conda environment of the integrated terminal

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Dynamic path",
            "type": "python",
            "request": "launch",
            "program": "myscript.py",
            "console": "integratedTerminal",
            "cwd": ".",
            "python": "${env:CONDA_PREFIX}/bin/python",
            "justMyCode": true
        },
    ]
}

Wenn I activate the conda environment with the path to the Python interpreter being /conda/envs/my_env/bin/python and then start the debugger of this configuration, I get the following output in the terminal

/usr/bin/env /conda/envs/my_env/bin/python /home/.vscode-server/extensions/ms-python.python-2023.8.0/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 45096 -- myscript.py
-X is reserved for implementation-specific arguments
usage: /bin/python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

This is unexpected, because the path /conda/envs/my_env/bin/python to the Python interpreter is correct.
Moreover, I have also followed the steps described in https://code.visualstudio.com/docs/editor/variables-reference#_how-can-i-know-a-variables-actual-value to see that the value of the python field in the configuration is actually the path to the Python interpreter.

When I replace the python field in the configuration by /conda/envs/my_env/bin/python the debugger runs.

Extension version: 2023.5.20
VS Code version: Code 1.78.0 (252e5463d60e63238250799aef7375787f68b4ee, 2023-05-03T20:09:00.748Z)
OS version: Windows_NT x64 10.0.19042
Modes:
Sandboxed: No
Remote OS version: Linux x64 4.4.0-19041-Microsoft
Remote OS version: Linux x64 3.10.0-1160.66.1.el7.x86_64
Remote OS version: Linux x64 4.4.0-19041-Microsoft
Remote OS version: Linux x64 4.4.0-19041-Microsoft

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz (8 x 2112)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
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
Load (avg) undefined
Memory (System) 15.75GB (1.59GB free)
Process Argv --crash-reporter-id 0d3cf624-62ed-41e9-9c0e-981ac1406d0e
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu-18.04
OS Linux x64 4.4.0-19041-Microsoft
CPUs Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz (8 x 2112)
Memory (System) 15.75GB (1.58GB free)
VM 0%
Item Value
Remote SSH: PROD_ADMIN
OS Linux x64 3.10.0-1160.66.1.el7.x86_64
CPUs Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz (4 x 2294)
Memory (System) 15.51GB (1.41GB free)
VM 100%
Item Value
Remote WSL: Ubuntu-18.04
OS Linux x64 4.4.0-19041-Microsoft
CPUs Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz (8 x 2112)
Memory (System) 15.75GB (1.58GB free)
VM 0%
Item Value
Remote WSL: Ubuntu-18.04
OS Linux x64 4.4.0-19041-Microsoft
CPUs Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz (8 x 2112)
Memory (System) 15.75GB (1.58GB free)
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscoreces:30445986
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30410667
cppdebug:30492333
vsclangdf:30486550
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
282f8724:30602487
pyind779:30671433
f6dab269:30613381
pythonsymbol12:30671437
a9j8j154:30646983
showlangstatbar:30737416
vsctsb:30705553
azdwalk:30721579
pythonms35:30701012
pythonfmttext:30731395
pythoncmvfstr:30731969
fixhidewlkth:30730051
hidesbindicator:30730055

Metadata

Metadata

Assignees

Labels

triage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions