In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today I will show you how to use Jupyter. The content of the article is good. Now I would like to share it with you. Friends who feel in need can understand it. I hope it will be helpful to you. Let's read it along with the editor's ideas.
Jupyter can also be a visual Debug,Jupyter team to release the first Debug plug-in and kernel.
How to choose the Python code editor? PyCharm, VS Code and Jupyter Notebook all have their own characteristics. Jupyter is suitable for data analysis, which requires visualization, and PyCharm is more suitable for a complete Python project. However, because of interactive operations, few developers think of using Jupyter as Debug.
Although many readers may think that Jupyter is enough for presentations and small experiments, there is not much demand for Debug, but making up for the missing link of Jupyter will make it easier to use, and Debug will be used as the default mode in the future.
Why does Jupyter need Debug?
Although Jupyter has good interactive performance, it also understands that for a large code base, it is better to use the traditional IDE. Therefore, in order to make up for this deficiency, the Jupyter project also hopes to strengthen the processing of a large code base through JupyterLab in the past few years.
However, JupyterLab still has a major drawback. It cannot do Debug visually, which limits further debugging. These days, the Jupyter team said that after months of development, they are happy to release the Jupyter Visualization Debugger for the first time.
Although this is only the first version, you can now set a common breakpoint Debug to view various variables, execution modules, and so on.
The use of the new tool is also simple, much the same as the common Debug approach. If readers want to install this new tool, first you need to install a front-end plug-in for JupyterLab:
Jupyter labextension install @ jupyterlab/debugger
As for the backend Kernel,Jupyter team, it is said that kernel needs to implement Jupyter Debug Protocol, so it can only use xeus-python for the time being:
Conda install xeus-python-c conda-forge
As long as the front end and back end are installed, we can use it directly. Developers also provide an online trial version of Debug, which can be experienced without installing anything.
Online Debug environment: https://hub.gke.mybinder.org/user/jupyterlab-debugger-hwxovlw4/lab/tree/examples/index.ipynb
Xeus-python: the first kernel that supports Jupyter Debug
Xeus, the C++ implementation of Jupyter kernel protocol, is not a kernel in itself, but a library that helps build the kernel. It is very useful when developers want to build Python, Lua and other language kernels with C # and C++ API.
There are already some kernels developed using xeus. The Xeus-python kernel is the kernel of choice when we do Python development, and it was released last year. Xeus-python was chosen by the Jupyter team as the first kernel to implement Debug mainly because it has the following two major advantages:
Xeus-python has a pluggable concurrency model that allows Control channel processes to be run in different threads
Xeus-python has a very lightweight code base, so iterating and updating are very convenient.
In the short term, xeus-python will have further plans to improve, such as adding Ipython magic methods, optimizing xeus-python 's PyPI, and so on.
Go deep into the front-end architecture of debugger
JupyterLab's debugger extension provides common functionality for users' habits of using IDE:
Sidebar with explorer, unordered list, source preview, and allow navigation to the call stack
The ability to set breakpoints directly next to the code (that is, in the code unit and in the code console)
A visual marker indicating the location of the current execution stop
When using a Jupyter notebook, the state of execution is saved in the kernel. But what if we execute a cell and then delete the entire cell, what if the user wants to run that code when Dubug?
As shown in the following dynamic diagram, the plug-in supports specific use cases and can view previously executed cell in read-only mode.
Enter the deleted cell
Debug the code console in JupterLab
Debug files in JupyterLab
Debugging can be enabled at the notebook level, and users can work on another notebook while debugging notebook.
Debug multiple notebooks at the same time
You can use tree viewers and tabular viewers to check variables:
Variable browser
The goal of JupyterLab's debugger plug-in is to be used with any kernel that supports debugging. Through the Debug Adapter Protocol,debugger plug-in, you can abstract the functions specific to a specific language and provide users with a matching debugging interface.
And the team plans to make major improvements to the debugger experience in 2020, such as support for rich rendering in variable browsers and conditional breakpoints in UI.
VS Code Visual Debug tool
Debug is a long way to go. Not long ago, Machine Heart also introduced a VS Code real-time visualization debug tool, which can also be used as a reference here. One of the future optimization directions is to help users find code problems in a more elegant and concise debug way, and the visual debug introduced earlier can quickly show data structures.
In terms of effect, this tool is more amazing and completely different from the traditional debug presentation, such as setting the breakpoint to line 32 to define a two-way linked list, and then line by line of code will show the corresponding data structure diagram on the right.
At the same time, it will be presented in different ways according to the data structure, such as trees, tables, curves and graphs.
At the same time, there are other customizable visual regulators, which can be more easily understood according to the different processing objects. Such as chart visualization, Plotly visualization, Tree visualization, grid visualization, text visualization and so on.
Plotly visualization
AST visualization
However, the developers of the debug tool for VS Code are discussing its support for Python, and the perfect support for Python will make the project more convenient and applicable. For debug, it doesn't matter whether you end up using the print () method, or making good use of assert statements, or setting breakpoints directly, including a variety of new debug tools. From the perspective of assistive tools alone, as long as it can improve productivity, no matter which debug tool it is, it is worth a try. These are all the contents of how to use Jupyter. For more information about how to use Jupyter, you can search for previous articles or browse the following articles to learn! I believe the editor will add more knowledge to you. I hope you can support it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.