Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to empower Jupyter Notebooks

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

What this article shares with you is about how to carry out empowering Jupyter Notebooks. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

The following is to empower Jupyter Notebook by introducing additional extension components and instructions for Jupyter Notebook. Help Python users to greatly improve the experience of using Jupyter Notebook and improve work efficiency.

Brief introduction

Jupyter Notebook is the most popular compilation environment for Python users today, especially for Python users who are keen on machine learning and data science. I found this artifact when I first came into contact with machine learning a few months ago and was fascinated by it after a little use. However, this feeling soon disappeared, because I found that the interface of Jupyter Notebook was very monotonous and lacked many useful features. Since then, I've been looking for cool techs that I can use in Jupyter Notebook to meet the daily needs of a Python user.

In this article, I will introduce some additional extension components and instructions for Jupyter Notebook to help Python users greatly improve their Jupyter Notebook experience and productivity.

In short, this article will teach you how to empower Jupyter Notebook!

Once you follow the instructions in this article, you will get (and are not limited to) the following features to refresh your Jupyter Notebooks:

1. You can switch freely between multiple Conda environments without restarting Jupyter Notebook. two。 Click to generate a "clickable directory" (I'm sure most people will like this feature! ). 3. A very useful draft test area (this is my favorite feature! )-you can run and test code in this area without changing anything in Jupyter Notebook. 4. Code folding within the code unit-effectively fills the gap in such functionality in Jupyter Notebook. 5. Hide code cells with one click-this is an important feature in data visualization, because listeners are usually interested in diagrams rather than code! 6. A super cool variable checker. 7. A spell checker for Markdown cells. 8. The Zen mode necessary for writing code at night. 9. A code snippet menu for dynamically adding commonly used Python structures, such as list understanding. 10. The final finale is one of the best features-a soothing midnight blue color scheme to save our tired eyes!

Enabling time

First of all, a white background can make our eyes tired after a long day's work, and we need to make sure that our Jupyter Notebook has an excellent dark theme to protect our eyesight. Trust me, once you use a dark theme, you will never want to switch back to a bright theme.

Use the following command to install package for changing Jupyter Notebook theme colors:

# Kill and exit the Notebook server# Make sure you are in the base conda environmentconda activate base# install jupyterthemespip install jupyterthemes# upgrade to latest versionpip install-after upgrade jupyterthemes has installed the above package, run the following command to change the Jupyter Notebook default bright theme to a graceful dark blue theme. Your eyes will be grateful for this move.

# Enable Dark Modejt-t onedork-fs 95-altp-tfs 11-nfs 115-cellw 88-T next, let's see if we can use the custom environment created in Anaconda as the kernel in Jupyter Notebook. This will ensure that we can switch kernels freely through the select environment feature in the kernel menu without having to restart Jupyter Notebook.

Suppose you create two custom environments in Anaconda: My NLP and Gym. To add this to Jupyter Notebook, you need to execute the following command:

# Stop and exit your Jupyter Notebook server first# Activate your environment in the terminal conda activate my_NLP# Install the IPython Kernel pip install ipykernel# Link your environment with Jupyter python-m ipykernel install-user-name=my_NLP# Repeat steps for the other environment, gym. Conda activate gympip install ipykernel python-m ipykernel install-user-name=gym

Now open your Jupyter Notebook, click the change Kernel option on the kernel menu, and you can see all the kernels, just click to activate them.

This is where the newly added kernel should appear. Pay attention to the soothing midnight blue theme

For all the other cool features I mentioned above, we simply execute the following command to install an extension component called nbextensions for Jupyter Notebook:

# Stop and exit your Jupyter Notebook server # Make sure you are in the base environmentconda activate base# Install the nbextensions pip install jupyter_contrib_nbextensions# Install the necessary JS and CSS files jupyter contrib nbextension install-- system

To start the Jupyter Notebook server, the fourth option on the start page is nbxtensions. Click it to see a range of features that Jupyter Notebook users expect to have.

Nbextensions interface

As you can see in the image above, nbextensions has a large expanded list and even seems to have some intense fears at first glance. But don't worry, we don't need all the extended applications. Here is a list of features that I find useful:

1. Directory (2)-you can generate a directory for the entire Jupyter Notebook with hyperlinks to each partition with just one click. two。 Draft test area-I think the best extension. It provides a separate area for users to test their code without interfering with the rest of the Jupyter Notebook. 3. Code folding-good functionality that does not need to be explained. 4. Hide all inputs-hides all code cells while always keeping the output and tag cells visible. This is very useful if you try to explain your results to non-technical people. 5. Variable Inspector-similar to the Variable Inspector window in Spyder IDE, saving us from the quagmire of Debugging. 6. Spell Checker-used to spell check the contents of cells in Markdown format. 7. Zen mode-hides the interference in the interface, allowing us to focus on important parts of the code. 8. Code template menu-A cool collection of common code templates, from List Comprehensions to Pandas and everything in between. This is not all, we can modify and add the custom code template we want.

The above 8 items contain the extensions I need on a daily basis, but I encourage you to try other extensions, such as ScrollDown,table_beautifier and Hinterland, which I find interesting.

Code template extensions are used in conjunction with working directory generation extensions

The above is how to carry out empowering Jupyter Notebooks. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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: 300

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

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report