The book recommends using Anaconda, but apt-get cuts it.
$ sudo apt-get install python3 python3-numpy python3-matplotlib
In Debian 8 (jessie), "python" refers to the Python 2.x family. "python3" will start the Python 3.x series.
$ python3
Python 3.4.2 (default, Oct 8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> x = np.array([0, 1])
>>> w = np.array([0.5, 0.5])
>>> np.sum(w*x)
0.5
If it is standard, I get angry when I try to draw a graph and say "I don't know what the screen is."
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> x = np.arange(0, 6, 0.1)
>>> y = np.sin(x)
>>> plt.plot(x,y)
(abridgement)
_tkinter.TclError: no display name and no $DISPLAY environment variable
It is okay if you drop it in a file by referring to Output the result of plotting with matplotlib on the server to a file | mwSoft.
>>> import numpy as np
>>> import matplotlib
>>> matplotlib.use('Agg')
>>>
>>> import matplotlib.pyplot as plt
>>> x = np.arange(0, 6, 0.1)
>>> y = np.sin(x)
>>> plt.plot(x,y)
[<matplotlib.lines.Line2D object at 0x7fcb0656ada0>]
>>> plt.savefig('sinwave.png')
sinwave.png (uselessly huge)
Recommended Posts