Skip to content

Notification when starting debugging and no interpreter has been selected #2494

Closed

Description

@qubitron

If you start debugging and no environment is selected, you just get an error with no explanation.

I suggest if no Python environment is selected, we pop up a notification:

You need to select a Python interpreter before you start debugging. 
Tip: click on "Select Python Environment" in the status bar.

[ Select Python Interpreter ] 

Activity

  1. changed the title [-]Banner when start debugging and no interpreter has been selected[/-] [+]Notification when starting debugging and no interpreter has been selected[/+] on Sep 6, 2018
  2. orware commented on Sep 6, 2018

    @orware

    I don't know if this is related exactly to what you're describing above, but today I started up a new folder / project for Python for my class and it wasn't debugging like the previous two folders / projects I had been working in.

    I ended up comparing some things between the two and noticed that one had this setup in the Workspace Settings file:

    {
        "python.pythonPath": "C:\\ProgramData\\Anaconda2\\python.exe"
    }
    

    Whereas the other one did not.

    Once I ended up adding that snippet in to the new folder I was able to debug successfully again but am not sure what I may have done to result in the change (I don't use Python a whole lot and haven't been using Visual Studio Code a whole lot either...I'm basically just looking for a quick/seamless way of running my simple Python code needed for class).

    This is basically the error I was receiving initially before making the change above:

    PS C:\my-python-project> cd 'c:\my-python-project'; ${env:PYTHONIOENCODING}='UTF-8'; ${env:PYTHONUNBUFFERED}='1'; ${env:PYTHONPATH}='c:\Users\example\.vscode\extensions\ms-python.python-2018.8.0\pythonFiles\experimental\ptvsd'; & 'python' '-m' 'ptvsd' '--host' 'localhost' '--port' '51262' 'c:\my-python-project\example.py'
    & : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At line:1 char:210
    + ... n.python-2018.8.0\pythonFiles\experimental\ptvsd'; & 'python' '-m' 'p ...
    +                                                          ~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (python:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
    
  3. qubitron commented on Sep 6, 2018

    @qubitron
    Author

    Omar Ramos (@orware) yes that's related! Instead of printing an error to the console we should pop up a notification with guidance on how to fix it.

    Debugging won't work if you haven't selected a Python interpreter. To set the interpreter you don't actually need to edit settings.json, you can click on the yellow warning icon in the status bar and select Anaconda:
    image

    Can you let me know if you see that warning icon and if debugging works after you click on it + select the desired interpreter? If not, we'll have to investigate further.

    As to why you have to keep modifying the setting for new projects, the Workspace Settings file only apply to the current folder you're working on, so you need to add that to every workspace you work in. To make it apply to all workspaces, you can edit your User settings file instead.

  4. orware commented on Sep 6, 2018

    @orware

    Dan Taylor (@qubitron) so I was about to respond and say I didn't see that in the status bar (but I was looking over on the far right, rather than the far left and then noticed it there).

    After clicking on it and selecting the Anaconda environment it was able to Run with or w/o debugging just fine so I think that solves the issue for me ;-).

    I did get the prompt regarding installing the new user version of VS Code a few weeks ago but decided against installing it for the time being, but I'll check to see if I can adjust that User Settings file you mentioned to make things perhaps a little easier for me down the road, but clicking on that icon once per folder is not too bad (now that I know where it is ;-).

  5. qubitron commented on Sep 7, 2018

    @qubitron
    Author

    Great, we'll have to think about how to make this more discoverable.

  6. qubitron commented on Sep 10, 2018

    @qubitron
    Author
  7. brettcannon commented on Sep 10, 2018

    @brettcannon
    Member

    ZhaoTongxue please open a separate issue for your problem as I don't think it is related to this issue.

  8. zhaoyewei commented on Sep 11, 2018

    @zhaoyewei

    Brett Cannon (@brettcannon) Sorry,I did it and deleted my comment on this issue. thank you.
    Dan Taylor (@qubitron) I show my message on this issue(#2537 )

  9. 14 remaining items

  10. brettcannon commented on Sep 20, 2018

    @brettcannon
    Member

    This seems to always pop up when using Python 2.7.

  11. locked as resolved and limited conversation to collaborators on Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions