[PYTHON] I tried using Jupyter

Introduction

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.

Installation

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.

How to use

Start Jupyter

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.

1.png

** 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.

2.png

A screen where you can enter Python code will be displayed. Enter the code and press Shift + Enter to execute: Run Cells.

9.png

Markdown description

You can write sentences in Markdown notation by changing Cell to Markdown.

#How to use Jupyter
**Markdown**You can write in notation.

8.png

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

Inline display of matplotlib graph

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)

6.png

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

How to use shortcut keys

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.

7.png

Recommended Posts

I tried using Jupyter
Somehow I tried using jupyter notebook
I tried using parameterized
I tried using argparse
I tried using mimesis
I tried using anytree
I tried using aiomysql
I tried using Summpy
I tried using coturn
I tried using Pipenv
I tried using matplotlib
I tried using "Anvil".
I tried using Hubot
I tried using openpyxl
I tried using Ipython
I tried using PyCaret
I tried using cron
I tried using ngrok
I tried using face_recognition
I tried using PyCaret
I tried using Heapq
I tried using doctest
I tried using folium
I tried using jinja2
I tried using folium
I tried using time-window
[I tried using Pythonista 3] Introduction
I tried using Random Forest
I tried using BigQuery ML
I tried using Amazon Glacier
[Pythonocc] I tried using CAD on jupyter notebook
I tried using git inspector
[Python] I tried using OpenPose
I tried using magenta / TensorFlow
I tried to touch jupyter
I tried using AWS Chalice
I tried using Slack emojinator
I tried using PySpark from Jupyter 4.x on EMR
I tried using Rotrics Dex Arm # 2
I tried using Rotrics Dex Arm
I tried using GrabCut of OpenCV
I tried using Thonny (Python / IDE)
I tried server-client communication using tmux
I tried reinforcement learning using PyBrain
I tried deep learning using Theano
[Kaggle] I tried undersampling using imbalanced-learn
I tried shooting Kamehameha using OpenPose
I tried using the checkio API
[Python] I tried using YOLO v3
I tried asynchronous processing using asyncio
I tried VS Code's Jupyter notebook
I tried scraping
I tried PyQ
I tried AutoKeras
I tried papermill
I tried django-slack
I tried Django
I tried spleeter
I tried cgo
I tried using Amazon SQS with django-celery
I tried using Azure Speech to Text.