2020-01-15
--As of April 2019, the latest is "Python 3.7.3" --As of November 2019, the latest is "Python 3.8.0" --As of December 2019, the latest is "Python 3.8.1"
--The version of Python3 to be installed this time is "Python3.8.1". --Please read as appropriate when the latest version is released. --The development environment uses "Jupyter Notebook".
--Chapter 2: Installing Python3 --Chapter 3: Explanation and construction of virtual environment --Chapter 4: Installing Jupyter Notebook
2-1. Windows
Install Python 3.8.1 on Windows 10 using the official installer.
Download Stable Releases. Click "Download Windows x86-64 web-based installer" to start the download. A file (installer) called "python-3.8.1-amd64-webinstall.exe" will be downloaded.
Enter the following command
> python -V
OK if it is output (displayed) as follows
Python 3.8.1
Enter the following command
> py
OK if it is output (displayed) as follows
Python 3.8.1 ...(Information such as date (depending on installed version and environment))
Type "help", "copyright", "credits" or "license" for more information.
>>>
If ">>>" is displayed, it is OK. In this interactive mode, enter a Python3 program and press "Enter" to execute the program. To exit interactive mode, press "quit ()" or "[Ctrl] + [z] + [Enter]".
2-2. macOS
--Python 2.7 is installed by default --May replace Python 3.X in the near future --This is because macOS uses tools that use Python. --Here, we will install Python 3.X in a way that coexists with Python 2.7. --Install using the official installer on macOS 10.9 and later versions,
Download Stable Releases. Click "Download macOS 64-bit installer" to start the download. A file (installer) called "python-3.8.1-macosx10.9.pkg" will be downloaded.
Start the terminal
$ cd /Applications/Python\ 3.8/Install/
$ ./Install\ Certificates.command
Enter the following command
> python3 -V
OK if it is output (displayed) as follows
Python 3.8.1
Enter the following command
> python3
OK if it is output (displayed) as follows
Python 3.8.1 ...(Information such as date (depending on installed version and environment))
Type "help", "copyright", "credits" or "license" for more information.
>>>
If ">>>" is displayed, it is OK. In this interactive mode, enter a Python3 program and press "Enter" to execute the program. To exit interactive mode, use "quit ()" or "[control] + [d]".
--You can build multiple Python execution environments on one computer. --It is also possible to run multiple versions of Python and libraries. --Example) If you are developing two Python programs, X and Y, it will be useful if you use different versions of each.
Reference site for virtual environment
A Python virtual environment is created in units of folders placed in a specific location.
For example, if you build a virtual environment in C: \ env_test \` ``, libraries etc. will be placed under the`
env_test``` folder.
Delete the virtual environment folder (put it in the trash).
The virtual environment will be built for the number of software to be developed (a lot). Don't lose track of where you built your Python 3 virtual environment The virtual environment of Python3 is here! Create one place (folder), It is recommended to build a virtual environment under it. I,
¥Users¥hoge¥Documents¥dev¥python
Is set as the development environment (virtual environment) folder of Python3 and operated.
### Building a virtual environment
Start a command prompt (windows) or powershell (windows) or terminal (macos).
This time,
#### **`En in \ Users \ hoge \ Documents \ dev \ python_Build a virtual environment named wk.`**
``` c
First, move to the folder where you want to build the virtual environment.
#### **`Enter the following command (move folder)`**
```language
> cd C:\Users\hoge\Documents\dev\python
on macos
$ cd C:\Users\hoge\Documents\dev\python
Enter the following command (virtual environment construction)
> python -m venv env_wk
on macos
$ python3 -m venv env_wk
Just building a virtual environment doesn't make much sense. Activate the virtual environment you have built.
Move the folder to the built virtual environment. (Not required if moved)
Enter the following command (move folder)
> cd C:¥Users¥hoge¥Documents¥dev¥python
on macos
$ cd C:\Users\hoge\Documents\dev\python
Enter the following command (enable virtual environment)
> env_wk¥Scripts¥Activate.py
Or
> env_wk¥Scripts¥Activate.bat
on macos
$ env_wk\bin\
$ source ./activate
Once enabled, the virtual environment folder name will be displayed before the prompt `` (env_wk)>
`.
When the virtual environment is enabled, it will be displayed as follows
(env_wk) C:¥Users¥hoge¥Documents¥dev¥python>
To deactivate a virtual environment, run the deactivate
command.
You can see that the prompt returns to the standard notation and exits the virtual environment.
Enter the following command (disable virtual environment)
(env_wk) > deactivate
Enable the virtual environment and enter the following command.
Enter the following command
(env_wk) > pip install jupyter
If it fails, enter the following command and try again.
Enter the following command
(env_wk) > pip install -U pip
Enter the following command
(env_wk) > Jupyter Notebook
If the web browser starts and the `Jupyter`
screen is displayed, it is successful.
The standard libraries (functions) used in the fields of machine learning and data analysis are as follows. --Numpy (a function for efficient numerical calculation) --SciPy (Numerical analysis function for mathematics, science, engineering) --pandas (functions that support data analysis) --matplotlib (function for drawing graphs) --scikit-learn (function for machine learning)
Please install (add functions) at once.
Enter the following command
(env_wk) > pip install numpy scipy pandas matplotlib scikit-learn
If you can afford it, please refer to the following articles. Introduction of Python 3 which is the easiest in the world
Recommended Posts