[Cloud102] # 1 Let's get started with Python (Part 2 Jupyter Notebook Construction AWS Edition)

AGENDA 0. Introduction

  1. Installation
  2. Add SG and check operation
  3. How to use

0. Introduction

(1) Preface -This content is the second part of "[Cloud102] # 1 Let's get started with Python", Jupyter Notebook construction AWS edition. Click here for Part 1: http://qiita.com/nagahisa/items/f378ff23d93119cb3c60 ・ Actually, I intended to explain Jupyter Notebook in the latter half, but it seems that Jupyter Notebook will be used for GCP training (CPB100) etc., so I will explain it ahead of schedule. -However, I will not touch Spark or TensorFlow that CPB100 handles at all: laughing :, I aim to be able to handle Jupyter Notebook as a convenient Python study environment.

(2) Original information QIITA has content to put Jupyter on Ubuntu, so change this to the Amazon Linux version and use it. Jupyter begins http://qiita.com/taka4sato/items/2c3397ff34c440044978

(3) Precautions --The Python used this time is the ver.2.7 series introduced as "python" in Amazon Linux. ――There is also a ver.3 series in Python, and this will be the mainstay in the future. --There are some major specification changes in the ver.3 series, and there are some parts that are not compatible with the code developed in the ver.2 series. --If you want to build an environment on your own Mac / Windows, it is recommended to install both versions of Python and switch as needed (pyenv, virtualenv).

1. Installation

(1) Amazon Linux instance launch & SSH login

-Start the Amazon Linux created in the previous (*) environment preparation. (*)http://qiita.com/nagahisa/items/c6bd92992eef42dbe53a

-Launch the previously created instance from EC2 Dashboard> Instance 01.png

・ After starting, log in with the previous procedure

Command example on Mac:``` $ssh -i ~/.ssh/cloud102.pem [email protected]


## (2) Install Update and required components

 Do the following on Amazon Linux:

```$ sudo yum update
$ sudo yum -y upgrade
$ sudo yum install -y python-pip libpq-dev python-dev
$ sudo pip install -U pip
$ sudo /usr/local/bin/pip install ipython[notebook]
$ sudo /usr/local/bin/pip install numpy pandas matplotlib seaborn scikit-learn

・ First, Update:

$ sudo yum -y upgrade

002.png

003.png

-Introduction of pip command (some captures):

$ sudo pip install -U pip

004.png

-Install the main unit + alpha with the pip command (some captures):

$ sudo /usr/local/bin/pip install numpy pandas matplotlib seaborn scikit-learn

005.png

(3) SG (Security Group) correction

-Modified SG to accept access to the port that starts the Jupyter server (8080 / tcp this time)

-Added "8080 / tcp permission" to the SG created last time from VPC dashboard> Security group.

・ SG made before 010.png

・ Addition (although you can use 8000) 012.png

・ Completed 013.png

(4) First, start / access confirmation without Jupyter Login Password

-Create config file template

On Amazon Linux:``` $ jupyter notebook --generate-config

 ![020.png](http://qiita-image-store.s3.amazonaws.com/0/79389/bfacca0d-f9d2-c0a5-67fd-e9639a1c513d.png)


 -Add the following to the end of the config file

c = get_config() c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False c.NotebookApp.port = 8080


With a suitable editor:```
$ vi ~/.jupyter/jupyter_notebook_config.py

021.png

·Start-up

$ jupyter notebook

022.png

-Access with your browser and check the operation (without Login Password) 023.png

-If you can confirm the operation, stop the Jupyter server with "Ctrl + C"

(5) Set Jupyter Login Password to start and check access

・ Password creation

$ python -c "import IPython;print(IPython.lib.passwd())"

SS 2016-10-18 10.17.00.JPG

-Add Finger Print displayed in ~ / .jupyter / jupyter_notebook_config.py as follows

c.NotebookApp.password = u'The displayed character string starting with sha1'

・ Start again

$ jupyter notebook

025.png

-Access with your browser and check the operation (with Login Password) 026.png

3. How to use

(1) Notebook creation -Create a notebook by referring to the latter half of the original information (*).

(*) Jupyter begins http://qiita.com/taka4sato/items/2c3397ff34c440044978

(2) Since it's a big deal, I'll touch on statistical processing for a moment. -Copy the following into a notebook cell and execute (Ctrl + Enter)

%mathplotlib inline

import numpy as np
import mathplotlib.pyplot as plt

x = np.random.randint(0,100,10000)
plt.hist(x.bins=20)
plt.plot()

e49c7a95-cb7f-c120-8a75-57f81125eac8.png

Enjoy! :tada:

Recommended Posts

[Cloud102] # 1 Let's get started with Python (Part 2 Jupyter Notebook Construction AWS Edition)
[Cloud102] # 1 Let's get started with Python (Part 3 Jupyter Notebook Construction GCP Cloud Shell Edition)
[Cloud102] # 1 Get Started with Python (Part 1 Python First Steps)
Get started with Python! ~ ① Environment construction ~
Get Started with TopCoder in Python (2020 Edition)
Let's get along with Python # 0 (Environment construction)
[Blender x Python] Let's get started with Blender Python !!
Python hand play (let's get started with AtCoder?)
Get started Jupyter Notebook
Virtual environment construction with Docker + Flask (Python) + Jupyter notebook
Easy Machine Learning with AutoAI (Part 4) Jupyter Notebook Edition
Get started with Python! ~ ② Grammar ~
Let's get started with Python ~ Building an environment on Windows 10 ~
Link to get started with python
Easy Jupyter environment construction with Cloud9
How to get started with Python
Get started with Python in Blender
Linking python and JavaScript with jupyter notebook
How Python beginners get started with Python with Progete
Get started with Python in 30 minutes! Development environment construction & learn basic grammar
Get started with Python on macOS Big Sur
Getting started with AWS IoT easily in Python
A layman wants to get started with Python
❤️ Bloggers ❤️ "Beloved BI" ❤️ Let's get started ❤️ (For those who can make charts with Python)
I tried to get started with blender python script_Part 01
Data analysis environment construction with Python (IPython notebook + Pandas)
I tried to get started with blender python script_Part 02
Web application made with Python3.4 + Django (Part.1 Environment construction)
Django 1.11 started with Python3.6
1.1 Getting Started with Python
Getting Started with Python
3 Jupyter notebook (Python) tricks
Get started with MicroPython
Get date with python
AWS CDK with Python
Get started with Mezzanine
Getting Started with Python
[Cloud103] # 3 Jupyter Notebook again
Minimum knowledge to get started with the Python logging module
Get country code with python
Image processing with Python (Part 2)
Studying Python with freeCodeCamp part1
Getting Started with Python Functions
Get started with Django! ~ Tutorial ⑤ ~
Scraping with Selenium + Python Part 1
Get started with influxDB + Grafana
Let's run Excel with Python
Get Youtube data with python
Getting Started with Python Django (1)
CI environment construction ~ Python edition ~
Get started with Django! ~ Tutorial ④ ~
Studying Python with freeCodeCamp part2
Getting Started with Python Django (3)
Use Cython with Jupyter Notebook
Image processing with Python (Part 1)
Play with Jupyter Notebook (IPython Notebook)
Get started with Django! ~ Tutorial ⑥ ~
Solving Sudoku with Python (Part 2)
Let's write python with cinema4d.
Get thread ID with python
Image processing with Python (Part 3)