<Python> Build a dedicated server for Jupyter Notebook data analysis

TL;DR I tried to reproduce the steps when the remote server (Cent OS 6.8) was made a dedicated server for Jupyter Notebook. It is convenient because it can be used as a dedicated analysis server for teams.

environment

Test.png

1. Install Pyenv

Install Pyenv so that you can easily switch between multiple Python versions.

curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash

pyenv -vWhen the version is displayed with, ok

pyenv 20160509-74-ge93ae00

2. Install Anaconda with Pyenv

Anaconda is a distribution with a lot of data analysis analysis libraries. Jupyter is also in this.

pyenv update
pyenv install -l //Check the latest version of anaconda
pyenv install anaconda3-4.1.0 //Latest version installation
pyenv global anaconda3-4.1.0 //Default Python switches to anaconda

It takes some time to install, but it's OK if the version is displayed with `jupyter --version`

4.1.0

3. Install Nginx

Consider using one IP for multiple services, and use Nginx.

First, register repo so that you can get the latest Nginx

/etc/yum.repos.d/nginx.repo


 [nginx]
 name=nginx repo
 baseurl=http://nginx.org/packages/centos/6/$basearch/
 gpgcheck=0
 enabled=1

Update yum and install Nginx

sudo yum update
sudo yum install nginx

nginx -vWhen the version is displayed with, ok

nginx version: nginx/1.10.1

Include Nginx's Jupyter-specific configuration file jupyter.conf before creating it

/etc/nginx/nginx.conf


http {
  include /etc/nginx/conf.d/jupyter.conf;
}

Create jupyter.conf. Listen to 9999.

/etc/nginx/conf.d/jupyter.conf


location / {
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  proxy_set_header Origin "";
  proxy_pass http://127.0.0.1:9999;
}

Start Nginx

sudo service nginx start

4. Jupyter settings

Create a Jupyter config file

jupyter notebook --generate-config

jupyter notebookThe command launches the browser by default. Set the default port used by Notebook to 9999 while preventing it from booting.

.jupyter/jupyter_notebook_config.py


c.NotebookApp.open_browser = False
c.NotebookApp.port = 9999 

5. Finally Jupyter starts!

That's all you have to enter!

jupyter notebook

Access the IP of the server, and when the screen below appears, startup is complete. The files and directories of the directory where the command was entered are displayed.

Immediately press "New" to create a new file

Home.png

As the name of Notebook suggests, you can write code as a trial writing, and you can execute it line by line, like one line = one set of code. In my case, I imported all the required libraries in the first line so that autocomplete works.

Test.png

5. Easy ssh connection to Jupyter server

After setting the server port and user, it is troublesome to enter a long ssh command on the client side to connect to the remote, so make it possible to connect with `ssh jupyter`.

~/.ssh/config


Host jupyter
    HostName        IP_ADDRESS
    Port            SSH_PORT
    IdentityFile    SECRET_KEY
    User            USERNAME

Recommended Posts

<Python> Build a dedicated server for Jupyter Notebook data analysis
Data analysis for improving POG 2 ~ Analysis with jupyter notebook ~
Python for Data Analysis Chapter 4
Python for Data Analysis Chapter 2
Python for Data Analysis Chapter 3
Recommendation of Jupyter Notebook, a coding environment for data scientists
Snippet settings for python jupyter notebook
Build a Python environment and transfer data to the server
Preprocessing template for data analysis (Python)
Build a python environment on CentOS 7.7 for your home server
Build a comfortable psychological experiment / analysis environment with PsychoPy + Jupyter Notebook
Create a USB boot Ubuntu with a Python environment for data analysis
Python visualization tool for data analysis work
Build jupyter notebook on remote server (CentOS)
Run Jupyter notebook on a remote server
Data analysis python
A summary of Python e-books that are useful for free-to-read data analysis
Quickly build a python environment for deep learning and data science (Windows)
Build a lightweight server in Python and listen for Scratch 2 HTTP extensions
Prepare a programming language environment for data analysis
[CovsirPhy] COVID-19 Python Package for Data Analysis: Data loading
Data analysis in Python: A note about line_profiler
A well-prepared record of data analysis in Python
Data analysis with python 2
Data analysis using Python 0
Data analysis overview python
3 Jupyter notebook (Python) tricks
Python data analysis template
Data analysis with Python
[For data science] Oreore Jupyter cheat sheet [Jupyter Notebook / Lab]
Data analysis for improving POG 1 ~ Web scraping with Python ~
[For beginners] How to study Python3 data analysis exam
Build a python environment for each directory with pyenv-virtualenv
Data analysis environment construction with Python (IPython notebook + Pandas)
A server that echoes data POSTed with flask / python
[CovsirPhy] COVID-19 Python package for data analysis: S-R trend analysis
[CovsirPhy] COVID-19 Python Package for Data Analysis: Parameter estimation
python jupyter notebook Data preprocessing championship (target site: BicCamera)
Build a basic Data Science environment (Jupyter, Python, R, Julia, standard library) with Docker.
Build a data analysis environment with Kedro + MLflow + Github Actions
Shortcut key for Jupyter notebook
My python data analysis container
[CovsirPhy] COVID-19 Python Package for Data Analysis: Scenario Analysis (Parameter Comparison)
[Python] Notes on data analysis
[Understand in the shortest time] Python basics for data analysis
Which should I study, R or Python, for data analysis?
Python data analysis learning notes
Build a Python extension for E-Cell 4 on Mac OSX (Yosemite)
Build a Python environment offline
Simple HTTP Server for python
Library for specifying a name server and dig with python
Data analysis using python pandas
Build a Python environment with WSL + Pyenv + Jupyter + VS Code
Tips for data analysis ・ Notes
python3.8 venv environment jupyter notebook
A Python beginner first tried a quick and easy analysis of weather data for the last 10 years.
How to batch start a python program created with Jupyter notebook
Build and test a CI environment for multiple versions of Python
A simple data analysis of Bitcoin provided by CoinMetrics in Python
Build a local development environment for Lambda + Python using Serverless Framework
Try using virtualenv, which can build a virtual environment for Python