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

Test: Run By Line in Jupyter notebooks #133903

Closed
3 tasks done
DavidKutu opened this issue Sep 27, 2021 · 9 comments
Closed
3 tasks done

Test: Run By Line in Jupyter notebooks #133903

DavidKutu opened this issue Sep 27, 2021 · 9 comments

Comments

@DavidKutu
Copy link

DavidKutu commented Sep 27, 2021

Refs: microsoft/vscode-jupyter#5607

Complexity: 3

Authors: @roblourens, @DavidKutu

Create Issue


Setup

  • Use VS Code Insiders and the latest jupyter and python extensions
  • Make sure that you have python 3.7 or greater installed and on your path as python3 or python
  • Set up a python virtualenv:
mkdir jupyter-dbg
cd jupyter-dbg
python3 -m venv ipykernel-env
  • Activate the virtual environment

Mac/Linux:

source ipykernel-env/bin/activate

Windows:

ipykernel-env\Scripts\activate.bat
  • Install the latest version of ipykernel in the virtual environment, which has debugging support
pip install ipykernel
python3 -m ipykernel install --user
  • Open a .ipynb notebook file (You can use this one if you need one)
  • Pick the kernel from your virtual env
  • Set "jupyter.logging.level": "verbose"

Testing

  • Click the RBL button
    image
  • It should stop execution on the first code line, the RBL button should change to Run Next Line, and another button called Continue Execution should appear next to it
    image
  • Clicking Run Next Line should step into the next line, stepping into functions defined in the same cell, but not stepping into anything else (functions in other cells, other python files, other python packages, etc.)
  • Clicking Continue Execution should stop RBL, and continue executing the cell where it left off
  • Interrupting or Restarting the kernel should also stop RBL

More Testing

  • Use the cell toolbar on both positions, check that the Run by Line button doesn't move when you press it
  • Check on the panel, that Jupyter: Variables comes up and that your variables get updated after each step
  • Try using it only with the key bindings (each button shows how to do it)

Filing issues

File issues on the jupyter repo using the link above. Include the log from the Jupyter output channel

Known Issues

@bamurtaugh
Copy link
Member

bamurtaugh commented Sep 28, 2021

Any ideas why I get this prompt when I click the RBL button?

image

I followed the setup described here and got confirmation Installed kernelspec python3 in < User directory > after running python -m ipykernel install --user.

Selected the Python 3.9.7 kernel:

image

Tried moving the notebook to different directory levels (i.e. in and out of the jupyter-dbg / ipykernel-env folder) and also tried running pip install -U ipykernel in the integrated terminal again.

Attached Jupyter logs in case they're useful, otherwise wondering if I'm selecting an incorrect option or missing a common step? Jupyter9-28.txt

@roblourens
Copy link
Member

Do you have the python extension installed?

@bamurtaugh
Copy link
Member

Yes - v2021.9.1246542782.

@roblourens
Copy link
Member

Can you check that you got the latest version of the jupyter extension and don't have a reload pending, and give me a call if so?

@DavidKutu
Copy link
Author

what version of ipykernel comes up if you run pip show ipykernel?

@bamurtaugh
Copy link
Member

Can you check that you got the latest version of the jupyter extension

I have Jupyter extension v2021.9.1001281857 - I actually reinstalled it and reloaded before starting this TPI to make sure I would have the latest.

what version of ipykernel comes up if you run pip show ipykernel?

Version: 5.5.5 shows up. Seems like that's likely the issue based on the troubleshooting: Ensure that ipykernel version 6.0 or greater is installed in the environment you're using for your notebook.

Any thoughts why I'd have the wrong version even after following the steps above?

@bamurtaugh
Copy link
Member

Although I previously ran pip install -U ipykernel based on the troubleshooting guide, I ran pip3 install -U ipykernel since I figured maybe it was a pip versus pip3 issue, reloaded, and now I have Version: 6.4.1 and it seems to be working. Thanks for the help!

@gregvanl
Copy link

Seeing the same error as Brigit when I try to use Run By Line "Ipykernel setup required for this feature".
I got past that by doing a Run All, which prompted me to install ipykernel and something else (forgot what it was).
Now I'm hitting "ModuleNotFoundError" on import pandas as pd.
Is there another step to install or point to the import dependencies?

@roblourens
Copy link
Member

If you are using that Titanic.ipynb, you can install deps from the yml like conda env create -f golden_scenario_env.yml. If you have issues with that you could write some cells that don't have deps (a=123, print(a) etc)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants