LoginSignup
16
10

More than 5 years have passed since last update.

Raspberry PiでBokehを使おうとしたらエラーになった話

Last updated at Posted at 2018-05-22

この記事について…

普段はRaspberry Piとは無縁なプログラマだったんですが、斯く斯く然々で色々やってみることになりました。普段はWindowsしかいじらないのでLinuxは超初心者ですが、備忘録を兼ねて色々書こうと思います。
尚、2018/05/17現在 Raspbian Stretch Lite 2018-04-18リリースを使用しています。

Bokehでエラー

センサーで取得したデータをグラフ化するという場面に遭遇した為、今回はBokehライブラリを使うことにしました。

pip3 install bokeh

を実行してインストール、User Guideに沿って

python_file
  .
  .
from bokeh.plotting import figure, output_file, show
  .
  .

とコーディングして実行したところ、下記のエラーが発生。

Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.5/site-packages/numpy/core/__init__.py", line 16, in <module>
    from . import multiarray
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 18, in <module>
    from bokeh.plotting import figure, output_file, show
  File "/home/pi/.local/lib/python3.5/site-packages/bokeh/plotting/__init__.py", line 2, in <module>
    from ..document import Document; Document
  File "/home/pi/.local/lib/python3.5/site-packages/bokeh/document/__init__.py", line 7, in <module>
    from .document import Document ; Document
  File "/home/pi/.local/lib/python3.5/site-packages/bokeh/document/document.py", line 33, in <module>
    from ..core.json_encoder import serialize_json
  File "/home/pi/.local/lib/python3.5/site-packages/bokeh/core/json_encoder.py", line 45, in <module>
    import numpy as np
  File "/home/pi/.local/lib/python3.5/site-packages/numpy/__init__.py", line 142, in <module>
    from . import add_newdocs
  File "/home/pi/.local/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/home/pi/.local/lib/python3.5/site-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/home/pi/.local/lib/python3.5/site-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/home/pi/.local/lib/python3.5/site-packages/numpy/core/__init__.py", line 26, in <module>
    raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory

libf77blas.so.3ってなんじゃいと思ってググると、

sudo apt install libatlas-base-dev

してないんじゃない?みたいな話がGitHubにありました。
その通りに実行すると、無事にエラーは解消しました。
libxxxxxxxx系でエラーが出た場合は何らかのライブラリが未インストールじゃないか、真っ先に疑う癖をつけようと思います。

今回はQiitaの記事を参考にしながら「SPIとMCP3002を使用したアナログセンサーのデータ読み取り」+「Bokehで読み取りしたデータの加工(HTML化)」+「Flaskによる簡易Webサーバ構築」という構成を試しているので、また理解が深まったら投稿しようと思います。

参考
Raspberry Piで計測したデータをグラフ化 全部のせPython(SQLite + Bokeh + Flask)で作るグラフアプリ
https://qiita.com/Brutus/items/383acea6b2d294b45b6b

16
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
10