Skip to content
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

get_ipython in vscode debugger giving error #3209

Closed
decormatters opened this issue Jul 30, 2019 · 12 comments
Closed

get_ipython in vscode debugger giving error #3209

decormatters opened this issue Jul 30, 2019 · 12 comments

Comments

@decormatters
Copy link

Environment data

  • VS Code version: 1.36.1
  • Extension version (available under the Extensions sidebar): XXX
  • OS and version: mac 10.14.15
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
  • Relevant/affected Python packages and their versions: jupyterlab
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version vscode-python#3977): XXX

Expected behaviour

should be able to run debugger on run_line_magic functions

Actual behaviour

running the following in the debugger gives an error. non-get_ipython() lines seem fine.

get_ipython().run_line_magic('load_ext', 'autoreload')

Exception has occurred: NameError
name 'get_ipython' is not defined
  File "/Users/mattc/Documents/Playground/course-v3/nbs/dl2/01_matmul.py", line 22, in <module>
    get_ipython().run_line_magic('load_ext', 'autoreload')

based on converted notebook from fast.ai lesson 0
https://gist.github.com/decormatters/20f063e22f237bcb532566e4d3b1a1b2

Steps to reproduce:

  1. git clone https://github.com/fastai/course-v3
  2. create virtualenv using https://gist.github.com/decormatters/30595a2ad7b07156da3c596209a28292
  3. navigate to 01_matmul.ipynb
  4. convert to .py
  5. set vscode virtual env
  6. try debugging
@DonJayamanne DonJayamanne self-assigned this Jul 30, 2019
@DonJayamanne
Copy link
Contributor

Thanks for reporting this issue.
Please could you let me know how you are debugging this code?
Are you debugging a cell or debugging from the debugger toolbar?

@matthewchung74
Copy link

Hi Don, thanks for responding. I am debugging from the debugger toolbar. Here's my launch.json, which has nothing unusual.

{
  // 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: Current File",
      "type": "python",
      "request": "launch",
      "program": "${file}",
      "console": "integratedTerminal",
      "stopOnEntry": true
    }
  ]
}

@matthewchung74
Copy link

Hi Don, I uploaded the code here https://github.com/foobar8675/course-v3-vscode and fumbled through a video showing the bug https://youtu.be/9dFrkwcgRPA

@DonJayamanne DonJayamanne removed their assignment Aug 5, 2019
@DonJayamanne
Copy link
Contributor

Unfortunately get_ipython is only available within the context of an IPython session.
@rchiodo @IanMatthewHuff Please could you asist @foobar8675 in debugging their code using the new Data Science debugging functionality.

@rchiodo
Copy link
Contributor

rchiodo commented Aug 5, 2019

I don't believe this is a bug. It's behaving as designed. You have to debug a cell instead of debugging a file if you have line/cell magics.

Our insider's build has support for debugging cells. See Rong's video here:
https://twitter.com/davorabbit/status/1149062343231455238?lang=en

@rchiodo rchiodo closed this as completed Aug 5, 2019
@matthewchung74
Copy link

This is awesome! Thank you Rich and Don.

@matthewchung74
Copy link

matthewchung74 commented Aug 6, 2019 via email

@rchiodo
Copy link
Contributor

rchiodo commented Aug 6, 2019

I believe this is because we have it set to Just My Code. We could probably make that a user option. Feel free to enter a feature request.

@rchiodo
Copy link
Contributor

rchiodo commented Aug 6, 2019

This line here:
https://github.com/microsoft/vscode-python/blob/306de09b571ffeb2c4767a81c0a2c6d1382bab1b/src/client/datascience/jupyter/jupyterDebugger.ts#L310

If we set that based on a user option, I believe you'd be able to step into anything that was source based.

@matthewchung74
Copy link

thanks @rchiodo! one more question, I hope you don't mind ... do you have any idea for how debugging notebooks would work on a remote server? should it work the same as a local notebook, (assuming all the remote vscode python debugging stuff is set up?)

@rchiodo
Copy link
Contributor

rchiodo commented Aug 6, 2019

When you say remote, do you mean using VS Code's remote SSH connections? That should work exactly the same.
If you're referring to our Remote Jupyter Server URI, that's currently disabled as we're waiting on a security change from the debugger. Once that security fix is in place, that should also work exactly like normal debugging.

@matthewchung74
Copy link

matthewchung74 commented Aug 6, 2019 via email

@lock lock bot locked as resolved and limited conversation to collaborators Aug 13, 2019
@microsoft microsoft unlocked this conversation Nov 14, 2020
@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants