当前位置:网站首页>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 ~
边栏推荐
- Design principles and ideas: design principles
- 直播app运营模式有哪几种,我们该选择什么样的模式?
- All you want to know about large screen visualization is here
- 2022年最新《谷粒学院开发教程》:8 - 前台登录功能
- Pychart installation and setup
- 洛谷入门1【顺序结构】题单题解
- Vscode uses yapf auto format to set the maximum number of characters per line
- 创建数据库并使用
- 2022-2-15 learning the imitated Niuke project - Section 5 shows comments
- [MySQL] query valid data based on time
猜你喜欢

Talk about redis transactions

Admixture usage document Cookbook

2022年最新《谷粒学院开发教程》:8 - 前台登录功能

Eolink launched a support program for small and medium-sized enterprises and start-ups to empower enterprises!

Eolink 推出面向中小企业及初创企业支持计划,为企业赋能!

Keep valid digits; Keep n digits after the decimal point;

CAS之比较并交换

Fundamentals of software engineering (I)
![Luogu_ P1003 [noip2011 improvement group] carpet laying_ Violence enumeration](/img/65/413ac967cc8fc22f170c8c7ddaa106.png)
Luogu_ P1003 [noip2011 improvement group] carpet laying_ Violence enumeration

CAS comparison and exchange
随机推荐
ReentrantLock、ReentrantReadWriteLock、StampedLock
QT notes (XXVIII) using qwebengineview to display web pages
Teach you how to package and release the mofish Library
专家:让你低分上好校的都是诈骗
Redis CacheClient
Design of CAN bus controller based on FPGA (with main codes)
关于快速幂
Is flutter easy to learn? How to learn? The most complete introduction and actual combat of flutter in history. Take it away without thanks~
SQL parsing practice of Pisa proxy
Why can't the start method be called repeatedly? But the run method can?
Elegant custom ThreadPoolExecutor thread pool
Indexeddb learning materials
SQL parsing practice of Pisa proxy
Design of digital video signal processor based on FPGA (with main code)
原子操作类
Excuse me, is it cost-effective to insure sunshine Optimus Prime term life insurance No. 7? What are the advantages of this product?
ThreadLocal之强、弱、软、虚引用
Web chat room system based on SSM
Longest substring without repeated characters (Sword finger offer 48)
Jupiter core error