Use Jupyter Lab and Jupyter Notebook with EC2

I think that Jupyter Lab and Jupyter Notebook are often used for data analysis.

You can run it locally for a little processing, but when you do heavy calculations, you often want to use a calculator on the cloud instead of locally.

This time, I will make a note about how to run Jupyter Lab on AWS EC2 (Jupyter Notebook can be started by the same procedure).

Launch an EC2 instance and ssh connect

Log in to the AWS console and launch your instance. I think ubuntu with python is a good OS.

image-20201025213638286.png

Set the security group to allow connections only from your own IP.

image-20201025214549882.png

Ssh connect to the IP described in "Public IPv4 Address" in the instance overview and log in to the server.

Install Jupyter Lab

If your OS is ubuntu, python is already included.

$ python3 --version
Python 3.8.2

I will put pip and libraries.

sudo apt update
sudo apt install -y python3-pip

Refer to the Official Document and install according to the installation method recommended for the current version.

pip3 install jupyterlab

There was a WARNING that seemed to be installed in a place that is not in the PATH, so add it to the PATH.

WARNING: The scripts jupyter, jupyter-migrate and jupyter-troubleshoot are installed in '/home/ubuntu/.local/bin' which is not on PATH.
export PATH="$HOME/.local/bin:$PATH"

Start Jupyter Lab

At startup, jupyter-server specifies that all ips are allowed and starts.

jupyter-lab --ip='0.0.0.0'

If you connect to the address of http: // <EC2 instance public IPv4>: 8888 from your local PC with a browser, the token input screen will appear, and you can log in by entering it.

image-20201025221235818.png

Alternatively, you can log in directly by including token in the request parameter, such as http: // <EC2 instance public IPv4>: 8888 /? Token = <token>.

After logging in, you will be taken to the usual Jupyter Lab screen where you can start your analysis.

image-20201025221400207.png

The old-fashioned jupyter notebook can also be started and used by specifying the ip.

jupyter notebook --ip='0.0.0.0'

TIPS: If you want to log in with a password

If you have trouble entering the token, you can set a password.

$ jupyter notebook password
Enter password:  ****
Verify password: ****

It can be set with one command of (Reference: Running a notebook server — Jupyter Notebook 6.1.4 documentation).

image-20201025221725711.png

Recommended Posts

Use Jupyter Lab and Jupyter Notebook with EC2
Use Cython with Jupyter Notebook
Use markdown with jupyter notebook (with shortcut)
Use nb extensions with Anaconda's Jupyter notebook
Use apache Spark with jupyter notebook (IPython notebook)
How to use jupyter notebook with ABCI
Linking python and JavaScript with jupyter notebook
Use nim with Jupyter
Jupyter Notebook Settings-How to use (EC2 Amazon Linux 2)
Specify the browser to use with Jupyter Notebook. Especially Mac. (And Vivaldi)
EC2 provisioning with Vagrant + Jupyter (IPython Notebook) on Docker
Play with Jupyter Notebook (IPython Notebook)
How to use Jupyter Notebook
Use Bokeh with IPython Notebook
I want to use a virtual environment with jupyter notebook!
Allow external connections with jupyter notebook
Formatting with autopep8 on Jupyter notebook
Visualize decision trees with jupyter notebook
Make a sound with Jupyter notebook
Jupyter Notebook: 4 banal tips and tricks
Add more kernels with Jupyter Notebook
Convenient analysis with Pandas + Jupyter notebook
Easy to use Jupyter notebook (Python3.5)
A simple way to launch Jupyter Notebook / Lab and set a password
How to use jupyter notebook without polluting your environment with Docker
Use Jupyter Notebook as a unit test and manual creation tool
Memory leak in Python Jupyter Lab (Notebook)?
Build Jupyter Lab (Python) environment with Docker
I want to blog with Jupyter Notebook
Jupyter with PYNQ and high-level synthesis with Polyphony
Try SVM with scikit-learn on Jupyter Notebook
Use PIL and Pillow with Cygwin Python
[Explanation with image] Use pickle with Kaggle's NoteBook
Use BigQuery from your local Jupyter Notebook
Jupyter Notebook basic operations and shortcut keys
Use TPU and Keras with Google Colaboratory
Let's make jupyter lab easy to use
Jupyter Notebook Basics of how to use
Use vim keybindings on Docker-launched Jupyter Notebook
Easy! Use gensim and word2vec with MAMP.
[Jupyter Notebook memo] Display kanji with matplotlib
How to use Jupyter notebook [Super Basic]
Use Python and MeCab with Azure Functions
Rich cell output with Jupyter Notebook (IPython)
I wanted to use jupyter notebook with docker in pip environment (opticspy)
Use Jupyter Notebook with Visual Studio Code on Windows 10 + Python + Poetry + pyenv-win
Install matplotlib and display graph on Jupyter Notebook
Use jupyter notebook by connecting from another host
Jupyter Notebook memo
Mutual conversion between Qiita articles and Jupyter notebook
How to debug with Jupyter or iPython Notebook
[Jupyter Notebook / Lab] 3 ways to debug on Jupyter [Pdb]
Introducing Jupyter Notebook
When Html cannot be output with Jupyter Notebook
Data analysis for improving POG 2 ~ Analysis with jupyter notebook ~
Use dein.vim and ckw-mod with Windows7 32bit PowerShell
Jupyter Lab begins
Launch and use IPython notebook on the network
Verify NLC accuracy with Watson Studio's Jupyter Notebook
Interactively display algebraic curves with Python and Jupyter
Powerful Jupyter Notebook