当前位置:网站首页>Basic configuration and usage of Jupiter notebook
Basic configuration and usage of Jupiter notebook
2022-06-27 15:34:00 【User 8336546】
Preface
This article will introduce a powerful lightweight integrated development environment :Jupyter Notebook Basic configuration process and usage of .
brief introduction
Jupyter Notebook Is a web based application for interactive computing . It can be applied to the whole process of calculation : Development 、 Documentation 、 Run the code and display the results .——Jupyter Notebook The official introduction
In short ,Jupyter Notebook It's in the form of a web page , It can be in the web page direct Write and run code , The running results of the code will also be displayed directly under the code block . Such as in the process of programming need to write documentation , It can be written directly in the same page , Convenient for timely explanation and explanation .
Jupyter Notebook The main characteristics of :
- Programming with syntax highlighting 、 Indent 、tab The function of complement .
- You can run the code directly through the browser , At the same time, the running result is displayed under the code block .
- Display the calculation results in rich media format . Rich media formats include :HTML,LaTeX,PNG,SVG etc. .
- When writing instruction documents or statements to code , Support Markdown grammar
- Support use LaTeX Write a mathematical note .
install
1. Use as follows pip Command to install
pip install jupyter
2. Verify that the installation was successful
jupyter notebook --no-browser
If the following appears , be Jupyter Notebook Already in normal operation , Press Ctrl+c End operation
[I 00:38:58.788 NotebookApp] Serving notebooks from local directory: G:/Jupyter Notebook
[I 00:38:58.788 NotebookApp] Jupyter Notebook 6.2.0 is running at:
[I 00:38:58.788 NotebookApp] http://localhost:8888/?token=5f376397a2519ea17b951e5968ed4621a7a254efd1b7807d
[I 00:38:58.788 NotebookApp] or http://127.0.0.1:8888/?token=5f376397a2519ea17b951e5968ed4621a7a254efd1b7807d
[I 00:38:58.788 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 00:38:58.788 NotebookApp]
To access the notebook, open this file in a browser:
file:///C:/Users/%E7%8E%8B%E9%B9%8F%E5%AE%87/AppData/Roaming/jupyter/runtime/nbserver-31952-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=5f376397a2519ea17b951e5968ed4621a7a254efd1b7807d
or http://127.0.0.1:8888/?token=5f376397a2519ea17b951e5968ed4621a7a254efd1b7807d3. start-up
jupyter notebook
So far, it can be used normally Jupyter Notebook 了 .
** Be careful :** Normally, this command will automatically pop up the browser , If you encounter Unable to eject normally browser , Click here to Check out the solution .
4. Modify note path
Jupyter Notebook The default storage path of the file is C disc , For ease of operation , It is recommended to modify the path .
Enter the following command to find jupyter_notebook_config.py The path to the configuration file , And open .
jupyter notebook --generate-config
Ctrl+f Search for c.NotebookApp.notebook_dir = '' Code location , Take out the comments , Add the path you want to set between the single quotation marks , as follows :
c.NotebookApp.notebook_dir = 'G:/Jupyter Notebook'
Be careful : The path should use a backslash
preservation , sign out . Complete path modification .
Use
New notes
Here's the picture , Click the right side. New Pull down button , choice Python 3, A note is created .
rename
New notebook The default name is :Untitled.
Two renaming methods are recommended :
- When notebook Running time : Directly in
notebookpage , Click on the file name , You can modify the file name . - When notebook Stop running : Get into
Filetab , Select the file whose name you want to change ( Check the left side of the document ), Click onRenameButton , You can modify the file name .
Write code and run
Pictured , explain :
- New notebook By default, there is only one cell , In front with
In []As a mark , This cell is used to write code . - Click the button in the toolbar
function (Run)Run the code in the cell , The run results are displayed below the cells . In []The numbers added in the represent : The order in which the cell runs on the kernel .- Running code : In the tag
[]Added a*; The small circle in the upper right corner of the page becomes a solid . - End of code run :
[]Medium*Change to numbers ; The small circle in the upper right corner of the page becomes hollow .
preservation notebook
Save automatically : Yes notebook After modification , By default , In two minutes notebook Will be automatically saved .
Be careful :notebook When automatically saved , The corresponding log point file will not change
Save manually : Click the Save button to manually save .( The log point file changes )
Fallback log point
You can go back to the last record point at any time , To undo any changes made during this period .
** Log point file :** Each time a new one is created notebook when , Will automatically create a record point file , Used to record the notebook All States at a certain moment .
** Location :** stay notebook In the same level directory , There is one named .ipynb_checkpoints The catalog of , It contains every notebook Record point file of .
** Naming rules :**notebook The name of the file -checkpoint.ipynb
** Fallback log point :** Click on the File, Click... In the pop-up menu Revert to Checkpoint Date and time in , For fallback .
Change theme
For a better experience , You can change the default theme .
Install third party libraries jupyterthemes:
pip install jupyterthemes
If using Anaconda, Then use the following command :
conda install jupyterthemes
List all available topics :
jt -l
Various Theme show ( chart )
Use a topic :
jt -t The name of an available topic
Restore the default :
jt -r
Print out the command jt And all optional parameters :
jt -h
Some commonly used optional parameters :
Optional parameters | Meaning of parameters | The default value is |
|---|---|---|
-T | Toolbar Visible( The toolbar is visible ) | nothing |
-N | Name Visible( Name visible ) | nothing |
-kl | Kernel Logo Visible( kernel Logo so ) | nothing |
-f | Code Font( The font of the code ) | nothing |
-fs | Code Font-Size( Font size of the code ) | 11 |
-tf | Text Cell Font( The font of the text cell ) | nothing |
-tfs | Text Cell Font-Size( Font size of text cells ) | 13 |
-nf | Notebook Font(Notebook The font of ) | nothing |
-nfs | Notebook Font-Size(Notebook Font size of ) | 13 |
-ofs | Output Area Font-Size( The font size of the output area ) | 8.5 |
For more information on other parameters, click this link :https://github.com/dunovank/jupyter-themes
Specific use cases , I prefer onedork The theme style , So make changes on this topic .
jt -t onedork -f hasklig -cellw 80% -T -N -kl -altmd -fs 16 -ofs 14
Possible problems
Input jupyter notebook The command cannot pop up the browser normally
Enter the following command to find jupyter_notebook_config.py The path to the configuration file , And open .
jupyter notebook --generate-config
Ctrl+f Search for c.NotebookApp.password = Code location , After that ( Another line ), Input :
import webbrowser
webbrowser.register('chrome', None, webbrowser.GenericBrowser(u'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'))
c.NotebookApp.browser = 'chrome'** Be careful :** What we use here is chrome browser , Pay attention to chrome.exe The path is filled in correctly , Use Double slash .
preservation , sign out . Complete the modification .
Conclusion
In case of problems or usage, continue to add ~
边栏推荐
- Luogu_ P1007 single log bridge_ thinking
- Volatile and JMM
- Handling methods for NVIDIA deepstream running delay, jamming and crash
- Pycharm安装与设置
- 漏洞复现----34、yapi 远程命令执行漏洞
- Piblup test report 1- pedigree based animal model
- 老师能给我说一下固收+产品主要投资于哪些方面?
- 16 -- 删除无效的括号
- I want to buy fixed income + products, but I don't know what its main investment is. Does anyone know?
- E ModuleNotFoundError: No module named ‘psycopg2‘(已解决)
猜你喜欢

Programming skills: script scheduling

How QT sets some areas to be transparent in the background image

Use GCC to generate an abstract syntax tree "ast" and dump it to Dot file and visualization

Strong, weak, soft and virtual references of ThreadLocal

Professor huangxutao, a great master in CV field, was born at the age of 86. UIUC specially set up a doctoral scholarship to encourage cutting-edge students

Great God developed the new H5 version of arXiv, saying goodbye to formula typography errors in one step, and the mobile phone can easily read literature

Why can't the start method be called repeatedly? But the run method can?

ReentrantLock、ReentrantReadWriteLock、StampedLock

Creation and use of static library (win10+vs2022

E modulenotfounderror: no module named 'psychopg2' (resolved)
随机推荐
R language error
Synchronized与锁升级
ReentrantLock、ReentrantReadWriteLock、StampedLock
原子操作类
R language triple becomes matrix matrix becomes triple
Top ten Devops best practices worthy of attention in 2022
CAS comparison and exchange
Admixture usage document Cookbook
Pisa-Proxy 之 SQL 解析实践
Pycharm安装与设置
我想买固收+产品,但是不了解它主要投资哪些方面,有人知道吗?
Jupiter core error
Go error collection | when a function uses a return value with a parameter name
Difference between special invoice and ordinary invoice
Redis CacheClient
Interview question: rendering 100000 data solutions
关于TensorFlow使用GPU加速
Pychart installation and setup
On traversal of tree nodes
Design and implementation of reading app based on Web Platform