[PYTHON] Jupyter installation

I learned about the existence of a web-based notebook service called Zeppelin. I'm ashamed to say that I didn't know anything about "code can be executed in a notebook", so I was curious that it would be a good idea to keep a record of Python learning. After a little research, it seems that Python integration is possible with Zeppelin, but I tried to introduce it because there is something called Jupyter that is closer to Python.

environment

Windows10(64bit) Anaconda3 4.3.1 (If you include this, jupyter_core 4.3.0 will be installed)

Introduced Anaconda

According to Official, Jupyter is recommended to be installed as part of Anaconda rather than as a stand-alone installation. I haven't studied again, but I didn't know Anaconda, so I looked it up and found that it is one of the Python distributions and has a large library of numerical calculations and data science. It also includes a package management software called Conda, which seems to be able to cover the proper use of 2.x and 3.x and virtual environment construction (virtualenv / pyenv). Download Anaconda from here. Since it is a Windows 10 (64bit) environment, drop the corresponding installer and execute it. By the way, I thought about uninstalling Python 2.7, 3.5 that was originally included, but in StackOverflow I was told that I could leave it, so I left it for the time being.

I basically accepted the default setting, but I chose All Users. Also, I was a little surprised at the required capacity of 1.8GB.

Start Jupyter

After the installation is complete, at the command prompt If you type jupyter notebook, the server will start on port 8888 and will start up in your browser. To change the port, use jupyter notebook --port 9999, and not launch the browser with jupyter notebook --no-browser.

20170327_013.jpg

A list of files in the executed folder is displayed. To create a new notebook, select New → Python 3 (since this is the only one associated at this point). Enter the appropriate code in the cell that appears, Shift + Enter, and it will be executed. It also does indentation and color coding.

20170327_014.jpg

Install another version

【reference】 https://jupyter.readthedocs.io/en/latest/install-kernel.html

Each interpreter is called a kernel. To install 2.7, conda create -n py27 python = 2.7.12 ipykernel This will install it in C: \ ProgramData \ Anaconda3 \ envs \ py27. This is more about the world of Anaconda than Jupyter (Jupyter only uses the Anaconda environment), so you can call the Python 2.7 environment regardless of Jupyter. This alone is not related to Jupyter, so associate it as follows.

>activate py27
(py27) >python -m ipykernel install --user

Now when you start it again, you can also select python2. If you think that the name displayed here will be py27, it will be Python 2. Will the name of the folder where the environment is created be picked up? %APPDATA%\jupyter\kernels\python2

20170327_015.jpg

Deactivate the called py27 environment deactivate py27

Use of other commands

If you want to do something other than python, you can use the windows command prompt command by typing %% cmd in the cell. If done well, it will be possible to integrate various things.

20170327_016.jpg

(Added on 2019/02/10) Change of default directory

Many people have written it. Note that I needed to add a little. Execute an application called Anaconda Terminal that is installed at the same time as installing anaconda, generate a configuration file with the following command, and edit it.

(base) C:\Users\ikedak2>jupyter notebook --generate-config
Overwrite C:\Users\ikedak2\.jupyter\jupyter_notebook_config.py with default config? [y/N]y
Writing default config to: C:\Users\ikedak2\.jupyter\jupyter_notebook_config.py

Rewrite the parameter c.NotebookApp.notebook_dir. Note that for Windows you need to escape the backslash twice in a row.

jupyter_notebook_config.py


## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = 'C:\\Users\\ikedak2\\Jupyter_Memo'

This doesn't change it, so let's say you right-click on Jupyter Notebook from the Windows app list and open the file location. There is a Jupyter Notebook shortcut there, so open its properties. In my case: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)

--If there is a description of% USERPROFILE% at the end in "Link destination", delete it. --Fit the working folder to the specified directory After fixing the above two points, it started up as expected.

image

Summary

Now you can start Jupyter and use Python 2.7 and 3.6 for each notebook.

The relationship between Jupyter, anaconda, ipython, conda is difficult ... I also feel that the official documentation is extremely difficult to follow. --Anaconda: Python distribution (including jupyter) --conda: Anaconda's package management software --ipython: An extension of the python shell (that is, the shell). Features such as completion seem to be better than the default shell. It had a function called ipython notebook, which runs ipython from a browser (plus memo), but it was separated and became jupyter. --jupyter: Web-based notebook. Use ipython as backend.

In other words, understanding that the shell (interface) when using python from Jupyter is ipython, and the whole is included in the distribution called anaconda. In other words, Jupyter was a derivative of ipython, which is almost python itself, rather than close to Python. I will try zeppelin, which was the catalyst for me.

Recommended Posts

Jupyter installation
Jupyter installation error
jupyter and pandas installation
jupyter nbextension, nbextensions_configurator installation command
Django installation
Cuda installation
boto3 installation
Jupyter Tips 4
Pythia Installation
Jupyter nbextensions
Docker installation
Volatility installation
Python installation
Jupyter Tips 5
pip installation
Sphinx installation
Jupyter Tips 2
InstantOS 1 installation
Jupyter tricks
Python installation
pip installation
Kivy installation
ChaSen installation
Backtrader installation
pip installation
Installation of Anaconda3
Jupyter Notebook memo
Introducing Jupyter Notebook
centOS 7 installation error
Installation of CentOS 8
Theano installation notes
Jupyter study notes_006
Jupyter Lab begins
Jupyter process management
GMT installation part 2.
[PyTorch] Installation method
GMT installation part 1.
Tkinter installation (homebrew)
OpenCV3 installation battle
Powerful Jupyter Notebook
Python installation (Windows)
Golang on jupyter
Bash in Jupyter
pyenv installation notes
Jupyter on AWS
phycopg2 installation failed
Jupyter Study Note_002
Jupyter notebook password
Build Jupyter Hub
Jupyter Notebook memo
ipython notebook installation
Hydrogen installation notes
Jupyter study notes_008
django installation location
PostgreSQL 10.0 installation procedure
Jupyter study notes_004
PyPM-Local Package Installation
jupyter qtconsole config
blockdiag installation procedure
Jupyter study notes_001
Python installation 2020 (macOS)