New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
qubitron opened this Issue Sep 5, 2018 · 15 comments

Comments

Projects
None yet
6 participants
@qubitron

qubitron commented Sep 5, 2018

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 ] 

@brettcannon brettcannon added this to the September 2018 Sprint 1 milestone Sep 6, 2018

@brettcannon brettcannon changed the title from Banner when start debugging and no interpreter has been selected to Notification when starting debugging and no interpreter has been selected Sep 6, 2018

@orware

This comment has been minimized.

Show comment
Hide comment
@orware

orware Sep 6, 2018

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

orware commented Sep 6, 2018

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
@qubitron

This comment has been minimized.

Show comment
Hide comment
@qubitron

qubitron Sep 6, 2018

@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.

qubitron commented Sep 6, 2018

@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.

@orware

This comment has been minimized.

Show comment
Hide comment
@orware

orware Sep 6, 2018

@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 ;-).

orware commented Sep 6, 2018

@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 ;-).

@qubitron

This comment has been minimized.

Show comment
Hide comment
@qubitron

qubitron Sep 7, 2018

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

qubitron commented Sep 7, 2018

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

@qubitron qubitron added needs PR and removed needs spec labels Sep 7, 2018

@qubitron

This comment was marked as off-topic.

Show comment
Hide comment
@qubitron

qubitron Sep 10, 2018

@zhaotongxue was there an error message after that line? If you can let us know what the failure was then we can better take a look.

qubitron commented Sep 10, 2018

@zhaotongxue was there an error message after that line? If you can let us know what the failure was then we can better take a look.

@brettcannon

This comment has been minimized.

Show comment
Hide comment
@brettcannon

brettcannon Sep 10, 2018

Member

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

Member

brettcannon commented Sep 10, 2018

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

@zhaotongxue

This comment has been minimized.

Show comment
Hide comment
@zhaotongxue

zhaotongxue Sep 11, 2018

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

zhaotongxue commented Sep 11, 2018

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

@DonJayamanne

This comment has been minimized.

Show comment
Hide comment
@DonJayamanne

DonJayamanne Sep 11, 2018

@qubitron
Done, however the only want to display a message with a button results in VSC opening the launch.json file.

I.e. here's the UX:"

  • User does not select python path
  • User opens python file
  • User starts debugging
  • User gets a message + launch.json file is open

DonJayamanne commented Sep 11, 2018

@qubitron
Done, however the only want to display a message with a button results in VSC opening the launch.json file.

I.e. here's the UX:"

  • User does not select python path
  • User opens python file
  • User starts debugging
  • User gets a message + launch.json file is open

DonJayamanne added a commit that referenced this issue Sep 12, 2018

@qubitron

This comment has been minimized.

Show comment
Hide comment
@qubitron

qubitron Sep 15, 2018

@DonJayamanne I'm not sure I understand what your last comment means, can you rephrase?

qubitron commented Sep 15, 2018

@DonJayamanne I'm not sure I understand what your last comment means, can you rephrase?

@DonJayamanne

This comment has been minimized.

Show comment
Hide comment
@DonJayamanne

DonJayamanne Sep 15, 2018

User gets a message + launch.json file is open

When the error message is displayed, VSC will automatically open the launch.json file.

The gif is displayed below.
If we go with another approach, we don't have the ability to add a button to the error message.

DonJayamanne commented Sep 15, 2018

User gets a message + launch.json file is open

When the error message is displayed, VSC will automatically open the launch.json file.

The gif is displayed below.
If we go with another approach, we don't have the ability to add a button to the error message.

@DonJayamanne

This comment has been minimized.

Show comment
Hide comment
@DonJayamanne

DonJayamanne commented Sep 15, 2018

dbg_ux

@qubitron

This comment has been minimized.

Show comment
Hide comment
@qubitron

qubitron Sep 15, 2018

Let's go without the weird behavior and no button, at least that way the user for sure will learn how to use the interpreter selector!

qubitron commented Sep 15, 2018

Let's go without the weird behavior and no button, at least that way the user for sure will learn how to use the interpreter selector!

@DonJayamanne DonJayamanne reopened this Sep 15, 2018

@qubitron

This comment has been minimized.

Show comment
Hide comment
@qubitron

qubitron Sep 15, 2018

Also I noticed the select python environment is not visible in your gif, is there anyway to have that take priority over the other items in the status bar?

qubitron commented Sep 15, 2018

Also I noticed the select python environment is not visible in your gif, is there anyway to have that take priority over the other items in the status bar?

@DonJayamanne

This comment has been minimized.

Show comment
Hide comment
@DonJayamanne

DonJayamanne Sep 15, 2018

Yes, will do

DonJayamanne commented Sep 15, 2018

Yes, will do

@brettcannon

This comment has been minimized.

Show comment
Hide comment
@brettcannon

brettcannon Sep 20, 2018

Member

This seems to always pop up when using Python 2.7.

Member

brettcannon commented Sep 20, 2018

This seems to always pop up when using Python 2.7.

@brettcannon brettcannon reopened this Sep 20, 2018

@brettcannon brettcannon reopened this Sep 26, 2018

@brettcannon brettcannon closed this Oct 4, 2018

DonJayamanne added a commit that referenced this issue Oct 9, 2018

Revert to old approach of validating python path when debugging (#2808)
* For #2494
* Revert to old approach
* Improve tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment