AGENDA 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).
-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
・ 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
-Introduction of pip command (some captures):
$ sudo pip install -U pip
-Install the main unit + alpha with the pip command (some captures):
$ sudo /usr/local/bin/pip install numpy pandas matplotlib seaborn scikit-learn
-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
・ Addition (although you can use 8000)
・ Completed
-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
·Start-up
$ jupyter notebook
-Access with your browser and check the operation (without Login Password)
-If you can confirm the operation, stop the Jupyter server with "Ctrl + C"
・ Password creation
$ python -c "import IPython;print(IPython.lib.passwd())"
-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
-Access with your browser and check the operation (with Login Password)
(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()
Enjoy! :tada:
Recommended Posts