Continuing from last night's [Introduction to Data Scientists] Python Basics ♬ Functions and Classes, Chapter 2 Basics of Scientific Calculation, Data Processing, and Using Graph Drawing Library I will talk about environment construction though it is not in. 【Caution】 ["Data Scientist Training Course at the University of Tokyo"](https://www.amazon.co.jp/%E6%9D%B1%E4%BA%AC%E5%A4%A7%E5%AD%A6%E3 % 81% AE% E3% 83% 87% E3% 83% BC% E3% 82% BF% E3% 82% B5% E3% 82% A4% E3% 82% A8% E3% 83% B3% E3% 83 % 86% E3% 82% A3% E3% 82% B9% E3% 83% 88% E8% 82% B2% E6% 88% 90% E8% AC% 9B% E5% BA% A7-Python% E3% 81 % A7% E6% 89% 8B% E3% 82% 92% E5% 8B% 95% E3% 81% 8B% E3% 81% 97% E3% 81% A6% E5% AD% A6% E3% 81% B6 % E3% 83% 87% E2% 80% 95% E3% 82% BF% E5% 88% 86% E6% 9E% 90-% E5% A1% 9A% E6% 9C% AC% E9% 82% A6% I will read E5% B0% 8A / dp / 4839965250 / ref = tmm_pap_swatch_0? _ Encoding = UTF8 & qid = & sr =) and summarize the parts that I have some doubts or find useful. Therefore, I think the synopsis will be straightforward, but please read it, thinking that the content has nothing to do with this book.
Learn how to use Mumpy, Scipy, Pandas, Matplotlib.
I will build it with Raspi4. 【reference】 [Introduction to RasPi4] Environment construction; OpenCV / Tensorflow, Japanese input ♪
First, build these libraries in the following environment. The target is to install pytho3, numpy, scipy, pandas, matpotlib, jupiter notebook. The environment at the time of burning to the SD card is as follows That is, python 3.7.3 numpy 1.16.2 was installed.
$ python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> print(numpy.__version__)
1.16.2
>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'scipy'
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas'
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'matplotlib'
This time it seems that there are no dependencies other than numpy-scipy, but for the time being, I put them in the following order. With the following apt-get command, it was possible to install in a very short time (about 10 minutes in total).
$ sudo apt install jupyter-notebook
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install python3-matplotlib
$ sudo apt-get install python3-scipy
$ sudo apt-get install python3-pandas
For the time being, it seems that it was installed as follows.
$ python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
>>> print(scipy.__version__)
1.1.0
>>> import pandas
>>> print(pandas.__version__)
0.23.3
>>> import matplotlib
>>> print(matplotlib.__version__)
3.0.2
There are two typical syntaxes for loading a library from a program.
(1) import module name as distinguished name Example; import numpy as np Functions (functions) defined in the numpy module can be used in the form of np. Functions. (2) from module name import attribute Example; from numpy import random The same is true here, you can call random in numpy and use the more defined functions as random. Functions.
Although it is an explanation of% oresis% matplotlib used in Jupyter notebook, it is omitted because it is not used. If you run with% quickref, the command will appear.
something.py
import numpy as np
import numpy.random as random
import scipy as sp
import pandas as pd
from pandas import Series, DataFrame
import matplotlib.pyplot as plt
import matplotlib as mpl
import seaborn as sns
#%matplotlib inline
#%precision 3
When I try to run the above as python something.py, I get the following error:
ModuleNotFoundError: No module named 'seaborn'
Install seaborn. I was able to install it in 5 seconds.
$ pip3 install seaborn
...
Successfully installed seaborn-0.10.1
Now the error is gone.
-Installed the necessary libraries for Raspi4 from scratch ・ When installed with apt-get, it took about 10 minutes in total. ・ As you can see, I had a hard time with the WiFi settings and the Japanese localization settings.
・ Is it finally like that tomorrow? ??
Recommended Posts