Python development server construction procedure (AWS + Anaconda)

Introduction

This time, we will build a Python development server on Amazon Web Service (AWS). Anaconda is used to build the Python environment, and Jupyter Notebook is used as the IDE.

The author's environment is as follows.

item Contents
Machine MacBook Air 13-inch, Early 2015
OS OS X Yosemite 10.10.5
Mem 8 GB

Instance creation

This time, create an EC2 instance with the following configuration.

item Contents
Region Oregon
Instance type t2.small
EBS General purpose SSD 30 GB
Security group Inbound = TCP:22 & 8888, Outbount = all, Anywhere

SSH settings

Describe the following settings in ~ / .ssh / config (create a new one if there is no ~ / .ssh / config). XXXXX.pem is a private key file issued by AWS.

~/.ssh/config


Host (Describe any host name: ex. pydev)
hostname ec2-XXX-XXX-XXX-XXX.us-west-2.compute.amazonaws.com
identityfile ~/.ssh/XXXXX.pem 
user ec2-user

Log in to the server.

$ ssh pydev

Installation of required software

Install Git, tmux, Emacs, etc.

$ sudo yum -y install git tmux emacs gcc gcc-c++ python-setuptools python-devel postgresql-devel

After that, work on tmux.

$ tmux

Installing Anaconda environment

Execute the following command.

$ wget https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda3-4.0.0-Linux-x86_64.sh
$ bash Anaconda3-4.0.0-Linux-x86_64.sh
$ source .bashrc

Jupyter Notebook environment settings

Execute the following command

$ jupyter notebook --generate-config
$ source activate root
$ ipython
In [1]: from notebook.auth import passwd

In [2]: passwd()
Enter password: XXXXXX
Verify password: XXXXXX

Out[2]: 'sha1:XXXXXXXXXXXXXXXXXXXXXXXXXXXX'

Make a note of the output'sha1: XXXXXXXXXXXXXXXXXXXXXXXXXXXX'.

Describe the following settings in ~ / .jupyter / jupyter_notebook_config.py.

``~/.jupyter/jupyter_notebook_config.py ... c.NotebookApp.ip = '*' ... c.NotebookApp.open_browser = False ... c.NotebookApp.password = 'sha1:XXXXXXXXXXXXXXXXXXXXXXXXXXXX'


Start the Jupyter Notebook server with the following command.

$ jupyter notebook &


`/etc/rc.local`To`nohup jupyter notebook &`If you add, the Jupyter Notebook server will start automatically when the instance is restarted.

#Log in to Jupyter Notebook from your browser

From your local browser`http://[Server hostname or IP]:8888/`When you access, the login screen is displayed. You can log in by entering the password entered in the Jupyter Notebook environment settings.

#in conclusion

At this point, you have built a Python development environment on AWS EC2. With the current settings, the IP of the server will change when you restart, so it is better to fix it using Elasatic IP. If the machine power is insufficient, you can increase the instance type as appropriate.

#References
* [Amazon Web Service (AWS)](https://aws.amazon.com/jp/)
* [Anaconda](https://www.continuum.io/why-anaconda)
* [Jupyter Project](http://jupyter.org)


Recommended Posts

Python development server construction procedure (AWS + Anaconda)
Python (anaconda) development environment construction procedure (SpringToolsSuites) _2020.4
Python development environment construction
python2.7 development environment construction
Python + Anaconda + Pycharm environment construction
Anaconda python environment construction on Windows 10
Python environment construction (pyenv, anaconda, tensorflow)
[Python3] Development environment construction << Windows edition >>
Python development environment construction on macOS
Emacs Python development environment construction memo
Python3.6 environment construction (using Win environment Anaconda)
Python project environment construction procedure (for windows)
Python3 + venv + VSCode + macOS development environment construction
Environment construction procedure: Ubuntu + Apache2 + Python + Pyramid
Windows + gVim + Poetry python development environment construction
VS Code + Azure Functions + Python environment construction procedure
Python 3.3 in Anaconda
Python environment construction (Anaconda + VSCode) @ Windows10 [January 2020 version]
Environment construction (python)
Python development on Ubuntu on AWS EC2 (using JupyterLab)
Python --Environment construction
pyenv + anaconda + python3
Python environment construction
From Python environment construction to virtual environment construction with anaconda
python environment construction
Deployment procedure on AWS (2) Server (EC2 instance) environment settings
Python development environment with Windows + Anaconda3 + Visual Studio Code
Python development environment construction 2020 [From Python installation to poetry introduction]
QGIS3 Python plugin development environment construction with VSCode (macOS)
[Python] Django environment construction (pyenv + pyenv-virtualenv + Anaconda) for macOS
Procedure to exe python file from Ubunts environment construction
AWS SDK for Python (Boto3) development in Visual Studio 2017
Install django on python + anaconda and start the server
python> udp> echo server
AWS CLI installation procedure
python windows environment construction
homebrew python environment construction
Python package development notes
Web server construction commentary
Private Python learning procedure
Use Python 3.8 with Anaconda
About Python development environment
Procedure from environment construction to operation test of testinfra, a server environment test tool made by Python
Ubuntu (18.04.3) Web server construction
AWS CDK with Python
Anaconda3 environment installation procedure
Development environment in Python
Anaconda environment construction memo
DNS server in Python ....
Mac environment construction Python
python & jupyterlab container construction
Local server with python
Bluemix Python Microservices Development
Python environment construction @ Win7
Slackbot development in Python
Python environment construction on Mac (pyenv, virtualenv, anaconda, ipython notebook)
[Python] Anaconda environment construction (installation, startup, virtual environment, package management) Mac environment
Construction of Python local development environment Part 2 (pyenv-virtualenv, pip usage)
Explosive speed! Using Python Simple HTTP Server for kintone development
Python environment construction procedure memo using Docker on Windows10 Home