10 reasons why I use VS Code for Jupyter Notebooks | by Manpreet Singh Minhas | Nov, 2022


Read to learn about 10 awesome VS Code features for enhancing your Jupyter Notebook programming experience

Photo by Fotis Fotopoulos on Unsplash

I have worked with Python, Deep Learning and Computer Vision for almost 5 years, in both academic research and industrial settings. I had started with Jupyter Notebook but quickly switched to Jupyter Lab because of several reasons. And I loved using it until I started to use VS Code for programming. I am a big fan of writing proper CLI programs than creating notebooks for most tasks. However, for data analysis and quick visualizations, nothing beats the interactive nature of the Jupyter cells! Without even realising it, I have gotten so used to the features provided in VS Code that when it stopped working for me (due to a silly error) and I had to switch to Jupyter Lab briefly, I realized I can never go back!

In this article, I’ll share the top reasons that make working in VS Code tremendously productive.

1. Full IDE Capabilities: This alone is a reason strong enough to switch over. Unlike some of you out there, I am not a person who programs in text editors (vim, nano etc. [No disrespect.]) and uses a separate terminal for program compilation, execution etc. I absolutely love using IDEs for development. An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development [1]. These exist for a reason and having all their capabilities at your disposal while working with Jupyter Notebooks is a liberating experience. From auto completions to being able to use the same colour scheme that you are used to is something I am thankful for. The list of IDE benefits is quite long and out of the scope of this article.

Source: By the Author

2. Awesome remote development experience: In today’s world where cloud computing is prevalent, remote development is no longer optional but an integral part of a developer’s skills. Spinning up a remote instance, connecting to it and developing can be challenging for beginners. It can be difficult to start working with Jupyter Notebooks on the cloud. Setting up takes proper ssh access to the instance, followed by running Jupyter Lab (or Notebook) with correct options (e.g. port, start directory, no browser flag etc.) and finally finishing it with a port forwarding. All this is a piece of cake for experienced people but nonetheless are steps that need to be performed. Remote development in VS Code is incredible! In fact, it is so awesome that I have written an article about it. You can read about it here: Remote development and debugging on the cloud (AWS/Azure/GCP) for Deep Learning / Computer Vision using Visual Studio Code (VS Code). In short, your remote development experience on VS Code is as close as it gets to local development.

3. Debugger: The ability to debug and find the root cause of the issue or resolve a bug is crucial for any developer. Debugging using print statements is all good but you can go only so far with those. Using a debugger can improve productivity and performance tremendously. A proper debugger allows you to place breakpoints anywhere in your code, these can be conditional and then let you stop your program execution at the breakpoint. You will have access to all the local and global variables, stack trace etc. of the program. Moreover, you also would have the ability to step into, step out, step over, and resume execution. There is a debugger console (not always and not supported for every language) in which you can manipulate the local variables as you would in the interpreter. With VS Code, you can put breakpoints in your Jupyter Notebook and debug cells! How cool is that? This is one thing that I yearned for while working with notebooks.

Source: By the Author

4. Variable Viewer: VS Code supports the Jupyter: Variables view that allows you to inspect all variables in memory. It nicely formats pandas dataframes into tables! Pretty handy if you want to look at the content of certain variables without necessarily wanting to debug. You can click on the Variables button in the top Jupyter toolbar to open the variables tab.

Source: By the Author

5. Output size limit: This feature might not look like much but comes to the rescue when your notebook has a ton of printing. This causes Jupyter Lab (or Notebook) to freeze and hang depending on the large output. However, in VS Code the output is truncated to a set max size limit. And if you want to look at the entire output just click the hyperlink at the top of the output cell which opens the entire output in a separate read-only text tab.

Source: By the Author

6. Advanced Terminal Support: Well a powerful terminal is every developer’s dream right? You get access to the VS code terminal support. This includes splitting the terminal, opening multiple tabs and having it neatly available in a tab group that is accessible with a keyboard shortcut. What more do you want? I know Jupyter Lab does have terminal support but I never was able to get it to work.

7. Auto port forwarding: If you work with remote machines, port forwarding is something you would probably need. (Cough cough) Even if you want to use a Jupyter Lab or Notebook you would need to do port forwarding! For apps like FiftyOne, Steamlit, etc. also you would need port forwarding. The good news with VS Code is that it does it automatically for you and manual port forwarding is as easy as entering the port number. It is available in the terminal group for remote connections. Press ctrl+` (or cmd+`) to open the group and then click on the ports tab.

Source: By the Author

8. Powerful Git support: Apart from the native git support in VS Code and extensions for viewing history graphs, there is incredible support for Jupyter Notebooks too! This is also available in Jupyter Lab with an additional extension (not sure about Jupyter Notebook). The notebook changes are rendered nicely at the cell level including the cell content, metadata and output changes. However, combined with the VS Code features, the git experience becomes extremely pleasant.

Source: By the Author

9. Format cell or notebook: This is another great functionality. You can right-click on a cell and format the cell or the entire notebook. Just right-click and select format cell or format notebook. You can use the keyboard shortcuts too. This a really quick way to clean up your notebook and format using the formatter of your choice.

Source: By the Author

10. Auto cell run time: There are several instances where you may need to know the cell execution time. Importing the time module or Jupyter magic commands is always possible. However, VS Code natively gives you the cell execution time for every run. It is a pretty handy functionality.

Source: By the Author

We looked at the positive aspects of VS Code. However, nothing exists without flaws and VS Code has few of its own.

I have been using VS Code for a while and have a few drawbacks or shortcomings.

  1. VS Code server connection can become unstable at times. This can happen sometimes if your Jupyter Notebook is too large or you have multiple of those open.
  2. Sometimes the base environment that is used for starting the Jupyter Kernel is messed up and the kernel just doesn’t start. This can be easily fixed by Jupyter: Select Interpreter to Start Jupyter Server.
  3. Sometimes if you put your machine to sleep and don’t restart VS Code then the python kernels become non-available. A restart fixed this for me.

Apart from these points, I don’t have any complaints about VS Code.

To conclude, in this article I shared 10 reasons why I love to use VS Code for Juptyer Notebook development. I hope this was informative. If you have any additional features that you love and use regularly on VS Code, please do share! Same for Juptyer Lab! Thank you for reading the article. Follow for more tech content. You can connect with me on LinkedIn.

[1] https://en.wikipedia.org/wiki/Integrated_development_environment


Read to learn about 10 awesome VS Code features for enhancing your Jupyter Notebook programming experience

Photo by Fotis Fotopoulos on Unsplash

I have worked with Python, Deep Learning and Computer Vision for almost 5 years, in both academic research and industrial settings. I had started with Jupyter Notebook but quickly switched to Jupyter Lab because of several reasons. And I loved using it until I started to use VS Code for programming. I am a big fan of writing proper CLI programs than creating notebooks for most tasks. However, for data analysis and quick visualizations, nothing beats the interactive nature of the Jupyter cells! Without even realising it, I have gotten so used to the features provided in VS Code that when it stopped working for me (due to a silly error) and I had to switch to Jupyter Lab briefly, I realized I can never go back!

In this article, I’ll share the top reasons that make working in VS Code tremendously productive.

1. Full IDE Capabilities: This alone is a reason strong enough to switch over. Unlike some of you out there, I am not a person who programs in text editors (vim, nano etc. [No disrespect.]) and uses a separate terminal for program compilation, execution etc. I absolutely love using IDEs for development. An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development [1]. These exist for a reason and having all their capabilities at your disposal while working with Jupyter Notebooks is a liberating experience. From auto completions to being able to use the same colour scheme that you are used to is something I am thankful for. The list of IDE benefits is quite long and out of the scope of this article.

Source: By the Author

2. Awesome remote development experience: In today’s world where cloud computing is prevalent, remote development is no longer optional but an integral part of a developer’s skills. Spinning up a remote instance, connecting to it and developing can be challenging for beginners. It can be difficult to start working with Jupyter Notebooks on the cloud. Setting up takes proper ssh access to the instance, followed by running Jupyter Lab (or Notebook) with correct options (e.g. port, start directory, no browser flag etc.) and finally finishing it with a port forwarding. All this is a piece of cake for experienced people but nonetheless are steps that need to be performed. Remote development in VS Code is incredible! In fact, it is so awesome that I have written an article about it. You can read about it here: Remote development and debugging on the cloud (AWS/Azure/GCP) for Deep Learning / Computer Vision using Visual Studio Code (VS Code). In short, your remote development experience on VS Code is as close as it gets to local development.

3. Debugger: The ability to debug and find the root cause of the issue or resolve a bug is crucial for any developer. Debugging using print statements is all good but you can go only so far with those. Using a debugger can improve productivity and performance tremendously. A proper debugger allows you to place breakpoints anywhere in your code, these can be conditional and then let you stop your program execution at the breakpoint. You will have access to all the local and global variables, stack trace etc. of the program. Moreover, you also would have the ability to step into, step out, step over, and resume execution. There is a debugger console (not always and not supported for every language) in which you can manipulate the local variables as you would in the interpreter. With VS Code, you can put breakpoints in your Jupyter Notebook and debug cells! How cool is that? This is one thing that I yearned for while working with notebooks.

Source: By the Author

4. Variable Viewer: VS Code supports the Jupyter: Variables view that allows you to inspect all variables in memory. It nicely formats pandas dataframes into tables! Pretty handy if you want to look at the content of certain variables without necessarily wanting to debug. You can click on the Variables button in the top Jupyter toolbar to open the variables tab.

Source: By the Author

5. Output size limit: This feature might not look like much but comes to the rescue when your notebook has a ton of printing. This causes Jupyter Lab (or Notebook) to freeze and hang depending on the large output. However, in VS Code the output is truncated to a set max size limit. And if you want to look at the entire output just click the hyperlink at the top of the output cell which opens the entire output in a separate read-only text tab.

Source: By the Author

6. Advanced Terminal Support: Well a powerful terminal is every developer’s dream right? You get access to the VS code terminal support. This includes splitting the terminal, opening multiple tabs and having it neatly available in a tab group that is accessible with a keyboard shortcut. What more do you want? I know Jupyter Lab does have terminal support but I never was able to get it to work.

7. Auto port forwarding: If you work with remote machines, port forwarding is something you would probably need. (Cough cough) Even if you want to use a Jupyter Lab or Notebook you would need to do port forwarding! For apps like FiftyOne, Steamlit, etc. also you would need port forwarding. The good news with VS Code is that it does it automatically for you and manual port forwarding is as easy as entering the port number. It is available in the terminal group for remote connections. Press ctrl+` (or cmd+`) to open the group and then click on the ports tab.

Source: By the Author

8. Powerful Git support: Apart from the native git support in VS Code and extensions for viewing history graphs, there is incredible support for Jupyter Notebooks too! This is also available in Jupyter Lab with an additional extension (not sure about Jupyter Notebook). The notebook changes are rendered nicely at the cell level including the cell content, metadata and output changes. However, combined with the VS Code features, the git experience becomes extremely pleasant.

Source: By the Author

9. Format cell or notebook: This is another great functionality. You can right-click on a cell and format the cell or the entire notebook. Just right-click and select format cell or format notebook. You can use the keyboard shortcuts too. This a really quick way to clean up your notebook and format using the formatter of your choice.

Source: By the Author

10. Auto cell run time: There are several instances where you may need to know the cell execution time. Importing the time module or Jupyter magic commands is always possible. However, VS Code natively gives you the cell execution time for every run. It is a pretty handy functionality.

Source: By the Author

We looked at the positive aspects of VS Code. However, nothing exists without flaws and VS Code has few of its own.

I have been using VS Code for a while and have a few drawbacks or shortcomings.

  1. VS Code server connection can become unstable at times. This can happen sometimes if your Jupyter Notebook is too large or you have multiple of those open.
  2. Sometimes the base environment that is used for starting the Jupyter Kernel is messed up and the kernel just doesn’t start. This can be easily fixed by Jupyter: Select Interpreter to Start Jupyter Server.
  3. Sometimes if you put your machine to sleep and don’t restart VS Code then the python kernels become non-available. A restart fixed this for me.

Apart from these points, I don’t have any complaints about VS Code.

To conclude, in this article I shared 10 reasons why I love to use VS Code for Juptyer Notebook development. I hope this was informative. If you have any additional features that you love and use regularly on VS Code, please do share! Same for Juptyer Lab! Thank you for reading the article. Follow for more tech content. You can connect with me on LinkedIn.

[1] https://en.wikipedia.org/wiki/Integrated_development_environment

FOLLOW US ON GOOGLE NEWS

Read original article here

Denial of responsibility! Techno Blender is an automatic aggregator of the all world’s media. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – admin@technoblender.com. The content will be deleted within 24 hours.
artificial intelligencecodeJupyterlatest newsmachine learningManpreetMinhasNotebooksNovreasonsSingh
Comments (0)
Add Comment