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

What are the most commonly used configuration techniques for Jupyter Notebook

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces "what are the most commonly used configuration skills of Jupyter Notebook". In daily operation, I believe many people have doubts about the most commonly used configuration skills of Jupyter Notebook. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the questions of "what are the most commonly used configuration techniques of Jupyter Notebook?" Next, please follow the editor to study!

What is a Jupyter profile?

Configuration files, as the name implies, are files that can modify various configurations of Jupyter. To modify the default configuration options of Jupyter, you need to modify the properties of the corresponding configuration options in the configuration file jupyter_notebook_config.py.

This configuration file does not exist at first and needs to be generated manually. The way is simple: type jupyter notebook-- generate-config on the command line and execute, and the configuration file is created, located in C:\ Users\ Administrator\ .jupyter\.

Then we go to the main directory of the c drive and open the .jupyter folder to find the configuration file:

Jupyter_notebook_config.py

The configuration file is the key, which will be used later.

1. Change the default working directory

In general, the default working directory for Jupyter is C:\ Users\ Administrator\, which is not very refreshing and not easy to manage the project, so it is often necessary to create a separate Jupyter working directory file on other disks.

The configuration file jupyter_notebook_config.py was mentioned earlier, and the working directory is modified in it.

Open the configuration file jupyter_notebook_config.py with notepad

Crtl + F find the c.NotebookApp.notebook_dir element and delete the previous comment #

Enter the directory path you want to set in the following single quotation marks (note the double slash), and save it off; for example:

C.NotebookApp.notebook_dir = "E:\\ jupyter_notebook"

Modify the shortcut key, find the jupyter notebook shortcut icon in the win start menu, right-click to select the property, delete the last "% USERPROFILE%/" of the target value, and click OK to exit.

After these four steps, the working directory is modified, and no matter whether you enter Jupyter Notebook through shortcut keys or the command line, you can see the newly set directory, clean and refreshing.

two。 Change the default browser

Many friends have their own browser preferences and want Jupyter to run on the browser that is often used.

It is also relatively easy to change the Jupyter default browser. Take setting up a chrome browser as an example:

(1) find the installation path of the chrome.exe file and copy the path.

For example: upright C:\\ Program Files (x86)\\ Google\\ Chrome\\ Application\\ chrome.exe'

How to find it? Right-click the chorme icon and open the location of the file, as shown below:

(2) Open the configuration file jupyter_notebook_config.py with notepad

(3) Crtl + F to find the c.NotebookApp.browser element

(4) add the following code below the found record (note to replace it with your chrome.exe path):

Import webbrowser webbrowser.register ('chrome', None, webbrowser.GenericBrowser (ubiC:\\ Program Files (x86)\\ Google\\ Chrome\\ Application\\ chrome.exe')) c.NotebookApp.browser =' chrome'

Save the file. This is done. Restart Jupyter and it will run on the newly set browser.

3. Set login password

If you are sensitive to your Jupyter directory and don't want others to use it easily, you can set your login password. The steps are as follows:

Open the configuration file jupyter_notebook_config.py with notepad

Crtl + F find the c.NotebookApp.allow_password_change element, change it to: NotebookApp.allow_password_change=False, and delete the previous comment # to save the file

Go back to the windows command line, run jupyter notebook password, and follow the prompts to enter the new password (note that the password here is not displayed)

You can see that a json file was generated in the previous step and saved in the .jupyter folder in the same location as the configuration file. This json file holds a hash value generated by the password. Find the file, open it, and copy the hash.

Open the configuration file jupyter_notebook_config.py again

Crtl + F finds the c.NotebookApp.password element, adds the previous hash value to the end, and deletes the previous comment # to save the file; example:

C.NotebookApp.password = upright sha1bloc 67c9e60bb8b6pur9ffede08894254b2e042ea597d771089e11aed'

All set up here, restart Jupyter, you can enter a new password to log in.

4. Install the extension

What many people like about Jupyter is that it provides a wealth of plug-ins, including displaying code execution time, generating directories, displaying variable names, code block folding and other comfortable features.

The extension nbextensions must be installed before using the plug-in.

Install the whole process on the command line, as follows:

Install nbextensions and execute pip install jupyter_contrib_nbextensions

Install javascript and css files and execute jupyter contrib nbextension install-- user

Install configurator and execute pip install jupyter_nbextensions_configurator

Restart Jupyter Notebook and you can see the nbextension tag

5. Modify notebook styl

The style that comes with notebook can already meet the needs of daily use, and it is easy to implement if you want to transform notebook into your favorite style.

Execute the whole process on the command line, and the steps are as follows:

Install theme style Toolkit: pip install jupyterthemes

View available topics: jt-l

Switch theme (switch to chesterish theme): jt-t chesterish

Restore the default theme: jt-r

There are many other functions, such as font, style, width, screen ratio and so on.

Show the various styles that netizens try:

Chesterish

Grade3

Gruvboxd

Gruvboxl

Monokai

Oceans16

Onedork

Solarizedd

Solarizedl

At this point, the study of "what are the most commonly used configuration techniques for Jupyter Notebook" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Development

Wechat

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

12
Report