Japanese can be used with Python in Docker environment

environment

OS:Windows10 Home 1909 Docker:Docker Toolbox Docker version: 19.03.12

important point

I was ashamed to use Docker for the first time in Jupyter environment maintenance, and I didn't know much about Docker. I will write it with a sense of self-discipline. * Use docker-compose.yml

The Docker image is built on the basis of the Dockerfile. Once you build the Docker image, a cache will be created. Simply put, the cache speeds up the second and subsequent reads. If there is this cache, it will be used preferentially during build. Therefore, when you update the Dockerfile, use docker-compose build --no-cache to do a build that does not use the cache.

Please note that it may take a long time depending on the thing because it is a build that does not use a cache.

Dockerfile

FROM jupyter/datascience-notebook
RUN pip install --upgrade pip
RUN pip install jupyterlab
RUN jupyter serverextension enable --py jupyterlab

RUN curl -L  "https://moji.or.jp/wp-content/ipafont/IPAexfont/IPAexfont00401.zip" > font.zip
RUN unzip font.zip
RUN cp IPAexfont00401/ipaexg.ttf /opt/conda/lib/python3.8/site-packages/matplotlib/mpl-data/fonts/ttf/ipaexg.ttf
RUN echo "font.family : IPAexGothic" >>  /opt/conda/lib/python3.8/site-packages/matplotlib/mpl-data/matplotlibrc
RUN rm -r ./.cache

how to use

In a Windows environment, run it with Docker Quickstart Terminal.

Move to the directory containing dockerfile and docker-compose.yml corresponding to Dockerfile described in Dockerfile with cd, and execute the following command (Notes Please also check).

docker-compose build
docker-compose up -d

If you have not set the token value in docker-compose.yml (the empty value is assumed to be "set"), I think that the URL is output to Terminal (eg http://127.0.0.1: 8888 /? token = ...). Jupyter can be used by accessing it with any browser including its token value.

Confirmation method

Once Jupyter is available, run the following in Python:

import matplotlib
import matplotlib.pyplot as plt
plt.figure()
plt.title('Ah- A')
plt.ylabel('I- i')
plt.xlabel('U- Uu')

As a result, if the output looks like the image below, you can use Japanese! 日本語グラフ.png Thank you for your hard work!

in conclusion

After graduating from the Anaconda environment, we will finally move to the Docker environment! It was good that I was enthusiastic, but I was new to Docker and had only knowledge of the data analysis system, so I was not familiar with IT knowledge and stumbled many times. Actually, I gave up once to be able to use this Japanese.

Also, recent articles are only for mac environment, and it is hard to find articles for windows environment. However, the environment of the article on the windows environment changes over time, and even if you type the code as it is, it may not work. It's fun to improve those codes, but it's difficult when you're a beginner ...

Reference article

  1. I wrote a Dockerfile so that Japanese can be used in Jupyter's Docker image
  2. I didn't understand the difference between docker-compose'up',' build', and'start', so I summarized it

Recommended Posts

Japanese can be used with Python in Docker environment
Prepare python3 environment with Docker
Python knowledge notes that can be used with AtCoder
[Memorandum] Japanese keys cannot be used in python string.Template.substitute
Can be used in competition pros! Python standard library
I made a familiar function that can be used in statistics with Python
Build Mysql + Python environment with docker
Video cannot be loaded with Spyder in Python development environment
SSD 1306 OLED can be used with Raspberry Pi + python (Note)
Scripts that can be used when using bottle in Python
[Python] Building an environment for competitive programming with Atom (input () can be used!) [Mac]
List of tools that can be used to easily try sentiment analysis of Japanese sentences in Python (try with google colab)
Build Jupyter Lab (Python) environment with Docker
Using venv in Windows + Docker environment [Python]
Can be used with AtCoder! A collection of techniques for drawing short code in Python!
Create Python + uWSGI + Nginx environment with Docker
New features in Python 3.9 (1)-Union operators can be used in dictionary types
Python standard input summary that can be used in competition pro
Launch environment with LineBot + Heroku + Docker + Python
Introduced sip-4.14 in python3.2.2 environment with MacOS 10.7.4
Mathematical optimization that can be used for free work with Python + PuLP
I set the environment variable with Docker and displayed it in Python
Environment maintenance made with Docker (I want to post-process GrADS in Python
++ and-cannot be used for increment / decrement in python
Until youtube-dl can be used with Synology (DS120j)
Hello World with gRPC / go in Docker environment
Prepare the execution environment of Python3 with Docker
Functions that can be used in for statements
Create a virtual environment with conda in Python
[Python] Build a Django development environment with Docker
Create Nginx + uWSGI + Python (Django) environment with docker
Super easy! Python + Flask environment in Docker quickly
Handle zip files with Japanese filenames in Python 3
Create an image with characters in python (Japanese)
Work in a virtual environment with Python virtualenv.
Use Python in Anaconda environment with VS Code
Build PyPy and Python execution environment with Docker
[Docker] Create a jupyterLab (python) environment in 3 minutes!
Use python with docker
virtual environment in python
Python environment with docker-compose
Japanese output in Python
Development environment in Python
Virtual environment with Python 3.6
You will be an engineer in 100 days --Day 35 --Python --What you can do with Python
De-VBA Excel tool! Eliminate VBA tool with Python in environment where Python cannot be installed
Virtual environment construction with Docker + Flask (Python) + Jupyter notebook
Periodically execute python script with cron in venv environment
Basic algorithms that can be used in competition pros
[Python] OpenCV environment construction with Docker (cv2.imshow () also works)
ANTs image registration that can be used in 5 minutes
list comprehension because operator.methodcaller cannot be used in python 2.5
Operators ++,-cannot be used in python (difference from php)
Japanese output when dealing with python in visual studio
Non-linear simultaneous equations can be easily solved in Python.
[Redash] Standard library cannot be used in python function
Summary of statistical data analysis methods using Python that can be used in business
[Python] Introduction to web scraping | Summary of methods that can be used with webdriver
In Python3.8 and later, the inverse mod can be calculated with the built-in function pow.
Send Japanese email with Python3
I wrote python in Japanese