Install and set Jupyter Notebook to create a study note creation environment [Mac]

What is Jupyter Notebook?

Jupyter Notebook is a web application that allows you to create and share documents containing program code, formulas, diagrams, explanations, etc.

The following features are listed on the official website.

--Supports over 40 programming languages such as Python, R and Scala --You can share your notebook via email, Dropbox, GitHub, or Jupyter Notebook Viewer. --Notebooks are saved in json format with the extension ipynb, but can be converted to other formats such as html and pdf --The input code is processed interactively and can be output as images, videos, LaTeX, JavaScript, etc.

Other

--Markdown can be used as a description -Enclosed in $$, LaTeX commands are recognized and can be used (basically only mathematical formulas should be supported)

I like that.

Basically, it is for personal use by setting up a local server, but if you use Jupyterhub, you can use it even in a multi-user environment. I can do it.

Several other subprojects are officially supported, so if you're curious, you might want to check out the following:

kernel

In Jupyter, the kernel is the process of interactively processing the input code and returning the result.

IPython is used as the kernel that executes Python processing, but if you want to process other languages, you need to install the kernel for that language separately.

You may want to install the programming you want to study.

See below for available kernels.

Difference from Kobito

I think the big difference is the ability to process the code interactively.

Therefore, it is convenient to modify the code that you tried and write a description in Markdown and save it as it is as a document.

You may find it helpful to look at the Jupyter Notebook Viewer.

Jupyter installation

environment

Installation

The installation method is described in detail below.

I used pip because I installed it on Python2 series, but if I use pip3 it should be installed on Python3 series.

pip install jupyter

Start-up

You can start it with jupyter notebook.

If you execute it as it is, the executed directory will be used as the home of the notebook, so it may be better to create and move the directory for the notebook before executing it.

jupyter notebook

Check the command options below.

jupyter notebook --help
# or
jupyter notebook --help-all

Python3 kernel added

When installed with pip, the only kernel that can be used is Python2, and Python3 is not available from the beginning.

Make the Python3 kernel available by doing the following:

python3 -m IPython kernelspec install-self

When executed, the Python3 kernel will be added to / usr / local / share / jupyter / kernels.

If you want to install with pip3 and use Python2, it is as follows.

python2 -m IPython kernelspec install-self

Markdown for Jupyter

Please refer to the following.

Most notations are available, and syntax highlighting for programming languages is also possible.

Jupyter settings

Jupyter config files are put in ~ / .jupyter by default.

First, execute the following command to create a config file. When executed, a file called jupyter_application_config.py will be created in ~ / .jupyter.

jupyter notebook --generate-config

When you open the created file, you will see the commented out settings. Check the contents and enable the required settings.

I haven't checked all the settings, but I have set the following for the time being.

# The port the notebook server will listen on.
c.NotebookApp.port = 8080

# The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = u'/Path/to/notebooks/'

notebook_dir is the home directory setting for Jupyter notebooks.

By default, the directory where Jupyter is executed is the home, but I always wanted to set a specific directory as a notebook storage.

Executing LaTeX commands

Some LaTeX commands, such as formulas, can be executed by enclosing them in $$.

$$
\begin{align}
\sum_{k=1}^{\infty} \frac{1}{k^2} = \frac{\pi^2}{6}
\end{align}
$$

It's like that.

I have prepared a simple example in here, so please check it.

It seems that new command etc. can also be used.

Sharing and browsing notebooks using GitHub

If you manage the created notebook as a repository on GitHub, the notebook can be encoded and viewed from the GitHub page, and can also be viewed from Jupyter Notebook Viewer. I can do it.

In my case, I push the directory set as the notebook directory to GitHub as it is so that I can browse the notebook anytime, anywhere.

Since .ipynb_checkpoints can be created in various places, I try to ignore them with gitignore.

Recommended Posts

Install and set Jupyter Notebook to create a study note creation environment [Mac]
[Note] How to create a Mac development environment
A simple way to launch Jupyter Notebook / Lab and set a password
How to set up WSL2 on Windows 10 and create a study environment for Linux commands
Install Anaconda on Mac and upload Jupyter (IPython) notebook to Anaconda Cloud
[Note] How to create a Ruby development environment
Build a PYNQ environment on Ultra96 V2 and log in to Jupyter Notebook
How to quickly create a machine learning environment using Jupyter Notebook with UbuntuServer 16.04 LTS
Steps to quickly create a deep learning environment on Mac with TensorFlow and OpenCV
Building a Python environment on a Mac and using Jupyter lab
I want to use a virtual environment with jupyter notebook!
How to quickly create a machine learning environment using Jupyter Notebook with UbuntuServer 16.04 LTS with anaconda
Create a Python environment on Mac (2017/4)
How to build a LAMP environment using Vagrant and VirtulBox Note
I wanted to create a smart presentation with Jupyter Notebook + nbpresent
Use Jupyter Notebook as a unit test and manual creation tool
Building a Python development environment on Windows -From installing Anaconda to linking Atom and Jupyter Notebook-
How to quickly create a machine learning environment using Jupyter Notebook on macOS Sierra with anaconda
Specify the browser to use with Jupyter Notebook. Especially Mac. (And Vivaldi)
Create a python environment on your Mac
How to set up a jupyter notebook on ssh destination (AWS EC2)
[Development environment] How to create a data set close to the production DB
Script to create a Mac dictionary file
Create a Python3 environment with pyenv on Mac and display a NetworkX graph
[Python] How to save the installed package and install it in a new environment at once Mac environment
Build Linux on a Windows environment. Steps to install Laradock and migrate
I want to create a nice Python development environment for my new Mac
How to install Fast.ai on Alibaba Cloud GPU and run it on Jupyter notebook
Try creating a web application with Vue.js and Django (Mac)-(1) Environment construction, application creation
[Python] How to create a local web server environment with SimpleHTTPServer and CGIHTTPServer
I set up TensowFlow and was addicted to it, so make a note
Install matplotlib and display graph on Jupyter Notebook
How to create a Python virtual environment (venv)
Create a Mac app using py2app and Python3! !!
[Ubuntu] Install Android Studio and create a shortcut
Jupyter Study Note_002
Jupyter Study Note_003
Jupyter Study Note_007
Jupyter Study Note_005
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
A memo to create a virtual environment (venv) before Django
Install Python3 on Mac and build environment [Definitive Edition]
How to set up a Python environment using pyenv
How to build a Python virtual execution environment using Visual Studio Code and pipenv on a Windows machine (also Jupyter notebook)
Mac application for double-clicking to open Jupyter Notebook (* .ipynb)
[Windows] [Python3] Install python3 and Jupyter Notebook (formerly ipython notebook) on Windows
How to build a development environment for TensorFlow (1.0.0) (Mac)
It took me half a day to install Polyglot in the anaconda environment on my mac, so I'll leave a note
Create a decent shell and python environment on Windows
How to set up and compile your Cython environment
I made a tool that makes it a little easier to create and install a public key.
When I tried to install PIL and matplotlib in a virtualenv environment, I was addicted to it.
I want to set up a GUI development environment with Python or Golang on Mac
Steps to set up Pipenv, create a CRUD app with Flask, and containerize it with Docker
Create a Python environment
Recommendation of Jupyter Notebook, a coding environment for data scientists
Create a function to display images like Jupyter / RStudio [Docker]
Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
Add an extension to build a more comfortable Jupyter environment
How to import NoteBook as a module in Jupyter (IPython)
I want to start a jupyter environment with one command