Introduction to Python "Re" 1 Building an execution environment

Introduction

** Re-introduction to Python **, so I will write an article for reviewing the basic grammar of Python.

Just a year before I started programming, I was trying to make something out of Python. A year has passed since then, and now I am mainly developing web applications using Ruby.

The reason I came here and decided to review Python again was that I had a job. I am planning to get a job in April next year, and the companies that are planning to get a job are developing services using machine learning and deep learning. I don't get a job as a machine learning engineer, but I think it's easier to understand the service if I've touched it. I have the impression that Python has a wealth of machine learning libraries, so I decided to start by learning Python.

As I mentioned at the beginning, Python was the first language I touched when I started programming, but ** I'm forgetful I completely forgot about grammar etc. **, so I will re-introduce it while leaving this article. I will do it.

Target audience

--People who have programming experience and want to get started with Python --People who are interested in machine learning and are thinking of studying from Python

Caution

I started by reviewing Python's grammar because I wanted to use Python to implement machine learning and deep learning. Note that "code in Python" = "machine learning is possible" is not. If you are interested in machine learning and deep learning, but do not need to implement it if you understand the concept, I think that you should refer to articles and books for that purpose.

↓ The main subject is from here

Building a Python runtime environment

Introducing Jupyter Notebook

The Jupyter Notebook allows you to enter and execute Python code using a web browser. You can execute code that feels like an interactive shell, which is very convenient for moving your hands and learning about Python.

To be able to use Jupyter Notebook, it is quick to install Anaconda Navigator.

** * What is Anaconda Navigator? ** **

Anaconda Navigator is a distribution that contains a lot of software necessary for Python development. Convenient tools such as Jupyter Notebook and spyder are included from the beginning.

Anaconda Navigator installation instructions

Installation procedure for mac (official) Installation procedure for win (official)

If you start Anaconda Navigator installed according to the above procedure, you should see Jupyter Notebook in the menu.

I will post about the basic usage of Jupyter Notebook in another article.

Indispensable for data analysis! How to use Jupyter Notebook [For beginners]

Introduced Jupyter Notebook inside Docker container

From here, it is for those who do not want to pollute the PC environment. If you don't mind, you can install Jupyter Notebook by the above method.

It is an environment construction of jupyter notebook using docker, but please forgive it because this is a procedure for mac users.

1. Get a Docker image

Since the image is published on Docker Hub, use this. jupyter/scipy-notebook jupyter/docker-stacks

This time, I will create ipython_notebook as a working directory and work on it.

By the way, IPython Notebook is the old name for Jupyter Notebook. Originally it was a tool for Python, but now it seems that it has been renamed because it can execute other scripting languages such as Ruby.

Get the image.

ipython_notebook


$docker pull jupyter/scipy-notebook
$docker image ls #jupyter/scipy-Confirm that notebook is displayed

If you execute the last command and jupyter / scipy-notebook is displayed, it's OK.

2. Mount the host directory (preparation)

As we work, we want to mount the host directory, so create a code directory under / ipython_notebook.

First, Docker makes sure that / Users is a shared directory with Docker for Mac. (Because the ipython_notebook directory exists under Users this time) Please refer to this article for the confirmation method because it was easy to understand.

ipython_notebook


$mkdir code
$cd code
$pwd #We will use the result of this command later.

3. Create a container

Next, create a container from the image taken in 1. Also, when creating the container, mount the code directory created in 2 as volume.

Execute the following code to create a container that mounts the directory created in 2. It should be noted here that the ... part of / Users / ... / ipython_notebook / code differs from person to person. The volume specification is -v host directory path: directory path in the container, so paste the result of executing the pwd command earlier into the host directory path here.

ipython_notebook


$docker run -p 8888:8888 --name jupyter -v \
/Users/.../ipython_notebook/code:/home/jovyan/work \
jupyter/scipy-notebook

If you execute the above command, you will get the following execution result, so copy the character string below token =. スクリーンショット_2020-07-30_0_45_05.png

With the option -p 8888: 8888, accessing http: // localhost: 8888 from any browser will open the authentication page. Enter the authentication token copied in ↑ here, and enter a new password to log in. (The password you set will be required for the next login.)

Launch of the second transition

The Ctrl C container will be stopped when you stop the container executed above. When starting the container from the second time onward, execute docker start jupyter to start it. To stop the container, run docker stop jupyter to stop it.

ipython_notebook


#When stopping the container executed above
Ctrl + C
#When launching the container from the second time onward
$docker container start jupyter
#When stopping the container started by docker container start
$docker container stop jupyter

This completes the Jupyter Notebook environment construction when using Docker.

From the next time, I will write about the basic grammar of Python.

reference

-(Learning environment construction memo) Start Jupyter Notebook in Docker container. -Installation procedure for Anaconda Navigator mac (official) -Installation procedure for Anaconda Navigator win (official) -Indispensable for data analysis! How to use Jupyter Notebook [For beginners]

Recommended Posts

Introduction to Python "Re" 1 Building an execution environment
An introduction to Python Programming
An introduction to Python for non-engineers
[Python Tutorial] An Easy Introduction to Python
Building an environment to execute python programs on AWS EC2
[Python] Building an environment with Anaconda [Mac]
An introduction to Python for machine learning
An introduction to Python for C programmers
Building an environment that uses Python in Eclipse
Building an environment for executing Python scripts (for mac)
Building an Anaconda environment for Python with pyenv
Introduction to Python language
Introduction to OpenCV (python)-(2)
[Python] Create an asynchronous task execution environment + monitoring environment
Notes from installing Homebrew to building an Anaconda environment for Python with pyenv
Building an environment to comply with the Python coding standard (PEP8) with Eclipse + PyDev
An introduction to Python distributed parallel processing with Ray
Building an environment for natural language processing with Python
Python development environment construction 2020 [From Python installation to poetry introduction]
Building an environment to use CaboCha with google colaboratory
Introduction to Python Django (2) Win
An introduction to private TensorFlow
An introduction to machine learning
Introduction to serial communication [Python]
Building a Python virtual environment
[Introduction to Python] <list> [edit: 2020/02/22]
Introduction to Python (Python version APG4b)
An introduction to Bayesian optimization
Building a Python virtual environment
Introduction to Python For, While
Let's get started with Python ~ Building an environment on Windows 10 ~
Summary from building Python 3.4. * From source to building a scientific computing environment
An introduction to Python that even monkeys can understand (Part 3)
An introduction to Python that even monkeys can understand (Part 1)
An introduction to Python that even monkeys can understand (Part 2)
[Django] Memo to create an environment of Django + MySQL + Vue.js [Python]
Building a Python environment on Mac
[Introduction to Udemy Python 3 + Application] 58. Lambda
[Introduction to Udemy Python 3 + Application] 31. Comments
An introduction to Mercurial for non-engineers
Practice! !! Introduction to Python (Type Hints)
[Introduction to Python3 Day 1] Programming and Python
Error when building mac python environment
Building a Python environment on Ubuntu
[Introduction to Python] <numpy ndarray> [edit: 2020/02/22]
[Introduction to Udemy Python 3 + Application] 57. Decorator
Introduction to Python Hands On Part 1
[Introduction to Python3 Day 13] Chapter 7 Strings (7.1-7.1.1.1)
Django beginners tried building an environment
[Introduction to Python] How to parse JSON
[Introduction to Udemy Python 3 + Application] 56. Closure
[Introduction to Python3 Day 14] Chapter 7 Strings (7.1.1.1 to 7.1.1.4)
[Introduction to Udemy Python3 + Application] 59. Generator
Building a virtual environment with Python 3
[Introduction to Python3 Day 15] Chapter 7 Strings (7.1.2-7.1.2.2)
[Introduction to Python] Let's use pandas
Python (from first time to execution)
From Ubuntu 20.04 introduction to environment construction
Python Programming Workshop-Super Introductory Python Execution Environment
[Introduction to Python] Let's use pandas
[Introduction to Udemy Python 3 + Application] Summary