Skip to content

Invalid message: Found duplicate in "env": PATH when using virtual environment in Python 3.11 #20828

Closed

Description

Type: Bug

I get this error "Invalid message: Found duplicate in "env": PATH." when I use a Virtual environment to debug python code, but when I switch to the global python interpreter it works fine.

Extension version: 2023.5.10681722
VS Code version: Code - Insiders 1.77.0-insider (b60db78, 2023-03-10T05:24:23.805Z)
OS version: Windows_NT x64 10.0.22621
Modes:
Sandboxed: Yes

A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256198
vstes627:30244334
vslsvsres303:30308271
pythonvspyl392:30422396
pythontb:30258533
vsc_aacf:30263846
pythonptprofiler:30281269
vshan820:30294714
pythondataviewer:30285072
vscod805:30301674
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30404738
cppdebug:30492333
vsclangdf:30492506
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30618038
pylantcb52:30590116
pyindex848:30611229
nodejswelcome1:30587009
pyind779:30611226
pythonsymbol12:30651887
6233i204:30659907
pythonb192cf:30661257
funwalk2cf:30682975
pythonms35:30671666
03d35959:30680466
7ij38806:30677315

Activity

  1. added
    triage-needed
    on Mar 10, 2023
  2. karrtikr commented on Mar 10, 2023

    @karrtikr

    Can you use Python: Report Issue command instead, it auto-fills many of the details we need? Other than that:

    • Please provide the launch.json config you're trying to debug with.
    • Please provide the logs after debugging:
    Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

    XXX
    

  3. added
    info-needed
    on Mar 10, 2023
  4. Youssefbenhammouda commented on Mar 10, 2023

    @Youssefbenhammouda
    Author
        "launch": {
            "configurations": [{
                "name": "Python: Current File",
                "type": "python",
                "request": "launch",
                "program": "${file}",
                "cwd": "${workspaceFolder}",
                "console": "internalConsole",
                "justMyCode": true
            }]
    

    Here's the output after debugging:
    DAP Server launched with command: c:\Users{user}\Projects\python\simpleApp\venv\Scripts\python.exe c:\Users{user}.vscode-insiders\extensions\ms-python.python-2023.5.10681722\pythonFiles\lib\python\debugpy\adapter

  5. karrtikr commented on Mar 10, 2023

    @karrtikr

    Please provide the debug logs, set python.logging.level to debug in User settings, reload window, then perform the steps to reproduce before providing the logs.

    Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

    XXX
    

  6. karrtikr commented on Mar 10, 2023

    @karrtikr

    Perhaps .env file or some other file is sending the PATH variable.

  7. bersbersbers commented on Mar 30, 2023

    @bersbersbers

    Same issue here with v1.77.0 and v2023.6.0.

  8. bersbersbers commented on Mar 30, 2023

    @bersbersbers

    My launch config:

    {
                "name": "project",
                "type": "python",
                "purpose": [
                    "debug-in-terminal",
                    // https://github.com/microsoft/vscode-python/issues/19030
                    // "debug-test",
                ],
                "request": "launch",
                "program": "project/project.py",
                "args": [
                ],
                // Comment out to inspect additional output
                "console": "internalConsole",
                "justMyCode": false,
            },

    Removing "console": "internalConsole" fixes the symptoms of the issue.

  9. karrtikr commented on Mar 30, 2023

    @karrtikr

    Do you have a .env file somewhere specifying additional env vars? Please mention the contents if so.

  10. pppmlt commented on Mar 31, 2023

    @pppmlt

    I have the same issue since the latest update.. Without "console": "internalConsole" the code runs fine (but not in internal console).

    launch.json

    {
        // 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: Module",
                    "type": "python",
                    "request": "launch",
                    "program": "${workspaceFolder}/${relativeFileDirname}/${fileBasename}",
                    "env": {"PYTHONPATH": "${workspaceFolder}", "CONDA_PREFIX": "PATH\\TO\\CONDA\\ENV"},
                    "console": "internalConsole",
                    "internalConsoleOptions": "openOnSessionStart",
            }
        ]
    }
    

    vscode

    Version: 1.77.0 (system setup)
    Commit: 7f329fe6c66b0f86ae1574c2911b681ad5a45d63
    Date: 2023-03-29T10:02:16.981Z
    Electron: 19.1.11
    Chromium: 102.0.5005.196
    Node.js: 16.14.2
    V8: 10.2.154.26-electron.0
    OS: Windows_NT x64 10.0.19042
    Sandboxed: Yes
    
  11. svenmk commented on Mar 31, 2023

    @svenmk

    The same here. Everything worked nicely. Just updated this morning, now I'm getting the error when debugging tests. Without debugging, they run.

    I'm not having any .env file in my project dir.

    {
        "version": "0.2.0",
        "configurations": [  
            {
                "name": "Python: Current File",
                "type": "python",
                "request": "launch",
                "program": "${file}",
                "console": "integratedTerminal",
                "justMyCode": true
            },
            {
                "name": "Debug Unit Test",
                "type": "python",
                "request": "test",
                "justMyCode": true,
                "env": {
                    "PYTEST_ADDOPTS": "--no-cov",
                }
            }
        ]
    }
    PS> code -v
    1.77.0
    7f329fe6c66b0f86ae1574c2911b681ad5a45d63
    x64
  12. 33 remaining items

  13. karrtikr commented on Apr 11, 2023

    @karrtikr

    javiermtl Downgrading should be no longer needed, try pre-release mentioned in #20828.

  14. javiermtl commented on Apr 11, 2023

    @javiermtl

    javiermtl Downgrading should be no longer needed, try pre-release mentioned in #20828.

    Thanks, Kartik Raj (@karrtikr), it worked for me :)

  15. added
    verified
    needs PR
    on Apr 12, 2023
  16. svenmk commented on Apr 12, 2023

    @svenmk

    I can confirm that the problem is solved for me in the Pre-Release version. Thank you!

  17. TcDhlPro commented on Apr 12, 2023

    @TcDhlPro

    I can confirm that the problem is solved for me in the Pre-Release version. Thank you!

    Me Too!

  18. AlexCaranha commented on Apr 14, 2023

    @AlexCaranha

    Thanks, it worked for me.

  19. ppmarkus commented on Apr 14, 2023

    @ppmarkus

    Thanks kartik. Works well now.

  20. karrtikr commented on Apr 14, 2023

    @karrtikr

    Thanks everyone for confirming, we'll release a stable version with the fix very soon.

  21. locked as resolved and limited conversation to collaborators on May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-debuggingbugverifiedwindows

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions