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).
Log in to the AWS console and launch your instance. I think ubuntu with python is a good OS.
Set the security group to allow connections only from your own IP.
Ssh connect to the IP described in "Public IPv4 Address" in the instance overview and log in to the server.
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"
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.
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.
The old-fashioned jupyter notebook can also be started and used by specifying the ip.
jupyter notebook --ip='0.0.0.0'
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).
Recommended Posts