mac configuration jupyter notebook

Configure the startup path of the notebook

  • First find the path configuration file path, enter the following sentence in the terminal
jupyter notebook --generate-config

insert image description here

  • Open the configuration path file, by looking for 'c.NotebookApp.', and enter your own path
open /Users/hb23170/.jupyter/jupyter_notebook_config.py

insert image description here

Code auto-completion extension

  • First install the extension library
pip install jupyter_contrib_nbextensions

insert image description here

  • Enter jupyter contrib nbextensions install --user in the terminal
  • Install pip install jupyter_nbextensions_configurator this library
  • After the installation is complete, restart Jupyter notebook

Please add a picture description

theme extension

  • Installation: pip install jupyterthemes
  • Enter jt -l in the terminalPlease add a picture description
  • set your own theme
- #选择一种喜欢的主题 ,参数有:-t 主题 -f(字体) -fs(字体大小) -cellw(占屏比或宽度) -ofs(输出段的字号) -T(显示工具栏) -T(显示自己主机名)
jt -t
如:jt -t onedork -f fira -fs 13 -cellw 90% -ofs 11 -dfs 11 -T -T
#恢复默认主题
jt -r

hot key

Jupyter has two modes, command mode and edit mode

  • When the side of the current cell is blue, it means that it is in command mode at this time , press Enter to switch to edit mode
  • When the side of the current cell is green, it means that it is in edit mode , press Esc to switch to command mode

Command mode shortcut key:
  double-click D: delete the current cell
  Shift-Enter: run the current cell and jump to the next cell
  Alt-Enter: run the current cell and create a new cell below
  Tab: code completion A: create a new cell   B
  above :
Create a new cell below
  L: Add a line number to the code of the current cell
  Shift-M: Merge the selected cell or merge the current cell and the cell below
  Y: Convert the current cell content into code form
  M: Convert the current cell content into markdown form
  H: Display the shortcut key help
  F: Find and replace
  P: Open the command panel
  Ctrl-Enter: Run the current cell
  1-6: Set the current cell content as the title 1~6 format
  Shift+Up and down keys: Press and hold Shift to perform up and down key operations Check multiple cells
  L: Display the row number
  Ctrl + Enter: Execute the cell code
Shift + Enter: Execute the cell code and move to the next cell
Alt + Enter: Execute the cell code, create a new one and move to the next cell

plt drawing display Chinese
import matplotlib.pyplot as plt
plt.rc('font', family='SimHei', size=13)

_: access last output
__: access last output
_X: access history X lines of output
_iX: access history X lines of input, the lowercase letter "i" stands for "in".

magic command

  • %quickref show IPython quick reference
  • %magic Show detailed documentation for all magic commands***
  • %debug enters the interactive debugger from the bottom of the latest exception trace
  • %run script.py Execute script.py
  • %prun statement performs line-by-line performance analysis of statement through cProfile
  • %time statement test execution time of statement
  • %timeit statement tests the execution time of the statement multiple times and calculates the average
  • %who, %who_ls, %whos display variables defined in the interactive namespace, variable level of information/redundancy
  • %xdel variable deletes variable and attempts to clear all references to its object in IPython
  • !cmd Execute cmd in the system shell
  • output=!cmd args execute cmd and assign
  • %bookmark Use IPython's directory bookmarking system
  • %cd direcrory switch working directory
  • %pwd returns the current working directory (as a string)
  • %env returns the current system variables (as a dictionary)

おすすめ

転載: blog.csdn.net/F13122298/article/details/128097589