크롬 북에 Crostini에서 pip, matplotlib 및 Jupyter 설치

소개



Chromebook에서 Python을 사용하여 그래프를 그려보고 싶다고 생각해 여러가지 해 보았다.

pip



pip가 없었기 때문에 넣었다.
$ which pip
$ curl -O https://bootstrap.pypa.io/get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1622k  100 1622k    0     0  2592k      0 --:--:-- --:--:-- --:--:-- 2592k
$ sudo python get-pip.py 
Successfully installed pip-18.1 setuptools-40.6.3 wheel-0.32.3

여기를 참고했다.
Setting up a fresh crostini in Chrome OS · GitHub

matplotlib



꽤 솔직하게 들어가지 않는다.
$ pip install matplotlib

  _posixsubprocess.c:16:20: fatal error: Python.h: No such file or directory
   #include "Python.h"
                      ^
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for subprocess32
  Running setup.py clean for subprocess32
Failed to build subprocess32
Installing collected packages: numpy, six, cycler, kiwisolver, python-dateutil, pytz, subprocess32, backports.functools-lru-cache, pyparsing, matplotlib
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/numpy-1.15.4.dist-info'
Consider using the `--user` option or check the permissions.
$ sudo pip install matplotlib

  _posixsubprocess.c:16:20: fatal error: Python.h: No such file or directory
   #include "Python.h"
                      ^
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for subprocess32
  Running setup.py clean for subprocess32
Failed to build subprocess32
Installing collected packages: numpy, six, cycler, kiwisolver, python-dateutil, pytz, subprocess32, backports.functools-lru-cache, pyparsing, matplotlib
  Running setup.py install for subprocess32 ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-tssmeB/subprocess32/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-uigJgF/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    copying subprocess32.py -> build/lib.linux-x86_64-2.7
    running build_ext
    running build_configure
     _posixsubprocess_config.h is already up to date.
    building '_posixsubprocess32' extension
    creating build/temp.linux-x86_64-2.7
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c _posixsubprocess.c -o build/temp.linux-x86_64-2.7/_posixsubprocess.o
    _posixsubprocess.c:16:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-tssmeB/subprocess32/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-uigJgF/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-tssmeB/subprocess32/

조사하면, python-dev 넣어서 사이트 나오므로, 넣어 보았다.
$ sudo apt-get install python-dev

그 후, sudo pip install matplotlib 해야 했다.
위해 해봤다.
$ python
Python 2.7.13 (default, Sep 26 2018, 18:42:22) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/__init__.py", line 62, in pylab_setup
    [backend_name], 0)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 4, in <module>
    from . import tkagg  # Paint image to Tk photo blitter extension.
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/tkagg.py", line 5, in <module>
    from six.moves import tkinter as Tk
  File "/usr/local/lib/python2.7/dist-packages/six.py", line 203, in load_module
    mod = mod._resolve()
  File "/usr/local/lib/python2.7/dist-packages/six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "/usr/local/lib/python2.7/dist-packages/six.py", line 82, in _import_module
    __import__(name)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module>
    raise ImportError, str(msg) + ', please install the python-tk package'
ImportError: No module named _tkinter, please install the python-tk package
python-tk 같다. 원래, 데스크탑 환경이 아니기 때문에, 그래프 표시는 여러가지 귀찮은 것인가. IDE를 넣으면 좋을지도.

Matplotlib showing plots? : Crostini

What's the best Python IDE for crostini (hoping to avoid harsh crashing issues) : Crostini

Jupyter



그렇다면, Jupyter 넣을까라는 궁금해져 왔다.

Jupyter Notebook : Crostini

Running a notebook server — Jupyter Notebook 5.7.3 documentation
$ sudo pip install jupyter

정상적으로 들어갔다.
훌륭합니다.



결론



좋은 느낌으로 환경 구축할 수 있었다.
라즈파이라든지 GCP 사용해도 좋지만.
크롬북 훌륭합니다.
파이썬 3에서도 괜찮습니까?
마음이 가면, 해보자.

좋은 웹페이지 즐겨찾기