Recently, for the first time in Python, there was a useful tool called Jupyter (formerly IPython notebook), so I would like to introduce it. This time, I will describe from installation in Windows environment to simple usage. Jupyter can save Python executable code and its results together. The file format is saved with the extension: ipynb.
C:\> python -m pip install jupyter
After the installation is complete, start the browser with the following command.
C:\> jupyter notebook
** Supplement ** If the command was not found, it was in the Scripts folder under the Python installation directory.
At the command prompt, move the current to the directory where you want to save the file.
C:\> cd c:\ipython
c:\ipython>jupyter notebook
When the browser starts, the following screen will be displayed.
** Supplement ** When you start Jupyter, it uses port 8888 by default. If you want to change the port number or use a browser other than the standard browser, start it with the following command. If you want to operate with a browser other than the standard browser, use the URL displayed after starting jupyter.
jupyter notebook --port 9999 --no-browser
[I 13:35:47.793 NotebookApp] Serving notebooks from local directory: c:\ipython
[I 13:35:47.793 NotebookApp] 0 active kernels
[I 13:35:47.793 NotebookApp] The Jupyter Notebook is running at: http://localhost:9999/?token=c14fad948ae8309d7d89ce8b8c454693274209bb8f76f9c3
[I 13:35:47.794 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 13:35:47.795 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:9999/?token=c14fad948ae8309d7d89ce8b8c454693274209bb8f76f9c3
When the Jupyter screen opens, select "Python3" from the "New" menu to create the file.
A screen where you can enter Python code will be displayed. Enter the code and press Shift + Enter to execute: Run Cells
.
You can write sentences in Markdown notation by changing Cell to Markdown.
#How to use Jupyter
**Markdown**You can write in notation.
For how to write Markdown notation, I referred to the following site.
Convenient for writing sentences and writing notes, Markdown notation Markdown notation sample collection
It is a very convenient function and you can save the graph and Python code generated by matplotlib as a set.
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-3, 3, 0.1)
y = np.sin(x)
plt.plot(x, y)
By the way, if you do the following in the cell, the above % matplotlib inline
and ʻimport` will be unnecessary.
%pylab inline --no-import-all
On the Jupyter screen, press the ESC key to enter Command Mode. You can check the shortcut keys with keyboard shout cuts in the Help menu.
Recommended Posts