[PYTHON] Put Jupyter and Docker Compose on your Chromebook and use it as a light development environment!

Preface

Chromebook is a browser only, a machine that is premised on using the Internet, It is easy to think that You can actually use it as a simple Linux machine.

** 3 ways to use ** Very ** lightly **, ** fast **. ** Cheap **, ** As a terminal with batteries ** ** Highly recommended as a sub machine **.

In this paper, as a Linux mini / development environment, Starting with the basic usage of Chromebook (for development) ① Python environment as a local Jupyter Notebook (2) Container execution environment that can use Docker-Compose As a construction procedure and command, And write the communication code after that from scratch, Environment construction for super beginners ALL-IN-ONE memo. Recommended for those who want to program in earnest with a Chromebook. (2020/09 first draft created)

Prerequisite information

Hardware used

HP Laptop Chromebook HP Chromebook x360 12b 12inch 2in1 Convertible Type Intel® Pentium 4GB 64GB eMMC Japanese keyboard (model number: 8MD65PA-AAAC) (Renewal deadline: 2026)

About the "push" of the HP Chromebook x360 12b

In addition, if it is a small system and the main usage is like an Android tablet, Lenovo IdeaPad Duet Chromebook Is also recommended, but because the keyboard is a cover type The use in the crime shell type is not good, and it is not suitable for development. Also, there is no USBTYpeA, SD card, earphone jack, etc. I felt it was a disadvantage from the viewpoint of expandability, so I excluded it from the candidates.

On the contrary, if you do not use it like an Android tablet, If it is a slightly larger one such as a 14-inch type, the range of performance options will expand.

Personally, the good thing about Chromebooks is It feels like a tablet and is "light" to carry and start. If you use it as a main, 14 inch type is good, if you use it as a sub, There is a touch of 12 inches or less in terms of convenience and versatility even indoors, Is recommended.

How to get detailed system information

Access as below on the browser

Enter the following in the URL field


chrome://system/

Results (partial excerpt)


CHROMEOS_RELEASE_CHROME_MILESTONE
84

CHROMEOS_RELEASE_VERSION
13099.102.0

CHROME VERSION
84.0.4147.127

How to operate the ChromeBook itself. What to do in advance

Personally recommended shortcuts

「Ctrl + Alt + /」 List keyboard shortcuts

「Ctrl + W」 Close the current window

「Ctrl + Shift + V」 Paste the contents of the clipboard as plain text

「Ctrl +Window display key(□||)」 Take a screen capture

「alt + @ 」「alt +「 」 Make Window a fixed size on the left half (or right half) of the screen

「alt+^」 Switching between making the window the entire screen and making it the normal size

About Android apps

It can be installed normally from Google Play. Supported items are displayed (basically most of them are supported) Not all features work at full. The functions around the network seem to be a little unique. This feature is too convenient You should choose a model that can use a touchpad and can be used as a tablet. Like Chrome extensions, but also Android apps Shortcuts will be added in parallel with the ChromeBook apps.

Notepad / text editor

For the time being, it's a good idea to put in the one that is the most basic and has syntax highlighting. Let's put in an editor app called "Text". https://chrome.google.com/webstore/detail/text/mmfbcljfglbokpmkimbfghdkjmjhdgbg

There is also a way to insert VisualStudioCode etc. Anyway, it's "easy and light", so this is enough.

File / folder structure

From an application called "File" equivalent to Explorer "Downloaded" file (local file), "Linux (β)" file (terminal mount described later), "Play file" ≒ file as Android, And Google Drive can be accessed transparently. Many files and apps are completed locally, It's not that you can't do it without a Web / network.


Linux (β) function and construction of Python environment

A function to operate the terminal of Linux (Debian stretch). Introduced in ChromeOS ver.69 or later.

File / folder sharing

Copy and paste (clipboard sharing)

The clipboard is shared between the Linux side and the chromeOS side, For example, look up the command in the browser on the chromeOS side, Note that the shortcuts are different when trying to Paste. On the chromeOS side, press "Ctrl + C" and not "Ctrl + V". Paste with "Ctrl + Shift (⇧) + V" in the manner of the Linux terminal side. Of course, after starting Jupyter etc. You can write the code on the browser, so you can use "Ctrl + V".

Backup and restore of the entire Linux environment

I feel that there is little information, but what you should know is Being able to back up the entire linux environment using the "official" procedure. chromebook official help https://support.google.com/chromebook/answer/9592813?hl=ja You can rest assured if you save the backup directly to Google Drive etc.

By the way, with the Docker image of HackMD after performing all the steps in this article The capacity is about 1.2GB. Probably about 300MB to 400MB on the base.

Check the version of the entire terminal

#Check the terminal version below
cat /etc/debian_version
> 10.1

In addition, with the terminal up The setting screen is displayed by pressing "Ctrl + Shift + p". You can change the color of the theme.

Python3 version check

#Python2 is not included, Python3 is included.
# pip/pip3 is not included.

python -V
> -bash: python: command not found

python3 -V
> Python 3.7.3

which pip
>※None

pip installation

#Download the installer with the following command
curl -O https://bootstrap.pypa.io/get-pip.py

#Important: distuils.If you do not install util in advance, you will get the following error.
# ModuleNotFoundError: No module named 'distutils.util'
sudo apt-get install python3-distutils

# get-Run pip to deploy pip
sudo python3 get-pip.py 

#Make sure you have pip
which pip
> /usr/local/bin/pip

pip -V
> pip 20.2.2 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)

Installation of libraries such as Matplotlib

#I was able to introduce it in one shot.
sudo pip install matplotlib

#A module for Japanese tofu is also included.
sudo pip install japanize-matplotlib

#Also include pandas
sudo pip install pandas

#Also include seaborn
sudo pip install seaborn

Install and launch Jupyter Notebook

#Installation
sudo pip install jupyter

#Start (* Browser starts automatically on chromeOS side)
jupyter notebook

Port forwarding etc. on the terminal side and chromeOS side I was wondering if I had to set it It's easy and convenient because it seems to be directly connected! !!

Sample code to run on Jupyter Notebook

Create a new Notebook on the launched browser and You can check the communication by executing the following code.

python verification code


##Setting to display graph inline on Jupyter
%matplotlib inline

####Declare the use of required libraries
##Graph drawing library
import matplotlib.pyplot as plt

##Arithmetic calculation library
import numpy as np

##Library that supports Japanese display of matplotlib
import japanize_matplotlib

####Run below
#Draw graph
x = np.arange(0, 20, 0.1)
y = np.cos(x)
#plot
plt.plot(x,y)
#Give a label name
plt.xlabel('Cosine graph')
#display
plt.show()

Even if you don't bother to launch Jupyter on your Chromebook There are enough talks that Colaboratory is fine, There is a place where you can try it lightly locally That's why it's very convenient.


Using Docker

Docker installation

Use the procedure for installing on debian on the official Docker site as it is https://docs.docker.com/engine/install/debian/

While referring to the official website, press "Ctrl + Shift (⇧) + V" If you copy and paste the command, it's almost OK.

Uninstall if there is an older version

sudo apt-get remove docker docker-engine docker.io containerd runc

Installation of dependent packages

sudo apt-get update

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

Addition of Docker official GPG key

What is GPG? Is the installer genuine? An encryption mechanism used for verification.

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88

Addition of stable repository of Docker

Check the CPU architecture information and execute by referring to the x86_64 procedure.

lscpu
#Output ⇒ Architecture:        x86_64
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/debian \
   $(lsb_release -cs) \
   stable"

Installation of Docker itself

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Installation confirmation and communication

Confirmation that installation was successful

docker version
#Output ⇒
# Client: Docker Engine - Community
#  Version:           19.03.12
#  API version:       1.40
#  Go version:        go1.13.10
#  Git commit:        48a66213fe
#  Built:             Mon Jun 22 15:45:50 2020
#  OS/Arch:           linux/amd64
#  Experimental:      false

Communication execution

With the --rm option Since it can be deleted automatically when the container is closed, You don't have to store finished containers.

sudo docker run --rm hello-world
#output(part) ⇒ 
# Hello from Docker!
# This message shows that your installation appears to be working correctly.

Using Docker-Compose

Install Docker-Compose

Similarly, refer to the linux installation procedure on the official website. https://docs.docker.com/compose/install/

Download the latest stable version

sudo curl -L "https://github.com/docker/compose/releases/download/1.27.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Grant execution authority

sudo chmod +x /usr/local/bin/docker-compose

Check installed version

docker-compose --version
#Output ⇒ docker-compose version 1.27.1, build 1110ad01

Practical use of Docker-Compose: Use of HackMD

Simultaneous Markdown editor: HackMD server Try to stand up in an instant using Docker-Compose.

#It seems that git is included from the beginning
git clone https://github.com/hackmdio/docker-hackmd.git
cd docker-hackmd
#Start immediately
sudo docker-compose up
#Output ⇒ If the following information appears at the end, it can be started on port 3000.
# info: HTTP Server listening at port 3000

Access HackMD

Launch the chrome browser and access the following. http://localhost:3000/

HackMD (Markdown editor that can be used at the same time) in the local environment of chromebook Docker image is now easy to launch and use.

HackMD itself is a very good editing tool for Markdown, so It would be quite useful to use only this normally.

By the way, I saw information that the container cannot be accessed on localhost, For Chromebooks that have been updated with Chrome OS since January 2020, localhost is common in Chrome OS and Linux environment, For containers launched in Linux environment It can be accessed by "localhost: port number".

Stop HackMD

You can stop the running process with "ctrl + c". Haz that you can no longer access localhost: 3000.


Postscript, impressions, etc.

The Chromebook was easier to use than I expected!

First of all, the Chromebook is easy to handle, and it is recommended that it is "light" both in terms of startup and physicality. It's better to touch a tablet / smartphone than to touch a computer I think there are few psychological barriers, but it can be said that the computer is close to that feeling.

And it is also good that a considerable proportion of software can be used as an Android tablet than expected.

Since the data is basically stored on the cloud side, It is also convenient that there is less time and effort for data linkage as a sub machine.

Furthermore, if it becomes a simple development environment like this article, Don't you feel the loss of having one Chromebook?

I'm glad I got a very "light" development environment!

My personal opinion about the competition of notebook terminals as a development environment

Even for education, cheap terminals for Windows and Chromebooks are becoming widespread. Even if the first programming environment your child touches is Scratch, I feel that the environment to be touched next will be the environment like this article.

In recent years, the WLS2 environment has been prepared for Windows as well. Regardless of OS such as Windows, Mac, Chromebook It has become possible to develop a linux environment. This was a Mac advantage in the past, It means that Windows and Chromebooks are chasing hard.

Rather, GPU-based machine learning is difficult on Mac, so It can be said that Windows, which can be realized on gaming PCs, has taken a step forward as shown below.

A story about machine learning on a gaming PC and comparing the difference in CPU / GPU performance with Colabo [Windows machine learning environment construction procedure definitive edition. TF2.0 compatible]

If you want to program, the trend like Mac may change a little. (Although Mac is not bad either)

Of course, the creation of this article is also a Chromebook

Of course, this article itself is completed only with Chromebook. (It's natural because I only publish my own memo when I'm trying) If anyone finds it useful, I may update it again.

that's all.

Recommended Posts

Put Jupyter and Docker Compose on your Chromebook and use it as a light development environment!
Build a LAMP environment on your local Docker
Put Linux in your Chromebook and use R ...
Build a Python development environment on your Mac
Flutter in Docker-How to build and use a Flutter development environment inside a Docker container
How to run a Django application on a Docker container (development and production environment)
Use Docker and Jupyter as execution environment distribution means for data analysis / visualization related workshops
Build a Docker environment that can use PyTorch and JupyterLab
Building a Jupyter Lab development environment on WSL2 using Anaconda3
Building a Python development environment on Windows -From installing Anaconda to linking Atom and Jupyter Notebook-
How to use jupyter notebook without polluting your environment with Docker
Use Jupyter Notebook as a unit test and manual creation tool
Create a simple Python development environment with VS Code and Docker
[DynamoDB] [Docker] Build a development environment for DynamoDB and Django with docker-compose
Build a development environment using Jupyter and Flask with Python in Docker (supports both VS Code / code-server)
Build your Django app on Docker and deploy it to AWS Fargate
Create a python environment on your Mac
Build a web server on your Chromebook
Use WebDAV in a Portable Docker environment
Build a Python + bottle + MySQL environment with Docker on RaspberryPi3! [Trial and error]
Build a PYNQ environment on Ultra96 V2 and log in to Jupyter Notebook
Build a TensorFlow development environment on Amazon EC2 with command copy and paste
[Python] Build a Django development environment with Docker
python development environment -use of pyenv and virtualenv-
Build a Kubernetes environment for development on Ubuntu
Set up a Python development environment on Marvericks
Create a Python virtual development environment on Windows
Build a Python development environment on Raspberry Pi
Use a free GPU in your favorite environment
Easily prepare a Jupyter Notebook environment with Docker (Tensorflow and Graphviz are also available)
[Django] Use VS Code + Remote Containers to quickly build a Django container (Docker) development environment.
Until you create a machine learning environment with Python on Windows 7 and run it
Memo A beginner tried to build a Java environment and Japaneseize it on Ubuntu 18.04.2 LTS.