LoginSignup
5
5

More than 5 years have passed since last update.

転ばぬ先の杖-Pandas インストールでエラーが出た場合の対処法

Last updated at Posted at 2018-04-26

はじめに

Pandas使おうと思ってpipでインストールしたら、更にエラー出たりしてちょっとはまったので、ナレッジとして残します。

ケース1

まず、Pandasをpipでインストール

sudo pip3 install pandas

Collecting pandas
  Downloading https://www.piwheels.org/simple/pandas/pandas-0.22.0-cp35-cp35m-linux_armv7l.whl (23.2MB)
    100% |████████████████████████████████| 23.2MB 12kB/s 
Requirement already satisfied: python-dateutil>=2 in /usr/local/lib/python3.5/dist-packages (from pandas)
Requirement already satisfied: numpy>=1.9.0 in /usr/lib/python3/dist-packages (from pandas)
Collecting pytz>=2011k (from pandas)
  Downloading https://files.pythonhosted.org/packages/dc/83/15f7833b70d3e067ca91467ca245bae0f6fe56ddc7451aa0dc5606b120f2/pytz-2018.4-py2.py3-none-any.whl (510kB)
    100% |████████████████████████████████| 512kB 338kB/s 
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2->pandas)
Installing collected packages: pytz, pandas
Successfully installed pandas-0.22.0 pytz-2018.4

Pandasインストール後、開発途中のプログラムを実行してると急にメッセージ発生(プログラムは動作する)

RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa

急にメッセージが出てきて気になったので原因調査→Numpyのバージョンが古いと出る模様

とりあえず、Numpyをアップグレードする

sudo pip3 install --upgrade numpy

Collecting numpy
  Downloading https://www.piwheels.org/simple/numpy/numpy-1.14.2-cp35-cp35m-linux_armv7l.whl (6.3MB)
    100% |████████████████████████████████| 6.3MB 45kB/s 
Installing collected packages: numpy
  Found existing installation: numpy 1.12.1
    Not uninstalling numpy at /usr/lib/python3/dist-packages, outside environment /usr
Successfully installed numpy-1.14.2

Numpyをアップグレー後、開発途中のプログラムを実行すると更にエラー発生(プログラム異常停止)

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-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 "sqlite.py", line 35, in <module>
    from bokeh.plotting import figure, output_file, show
  File "/usr/local/lib/python3.5/dist-packages/bokeh/plotting/__init__.py", line 2, in <module>
    from ..document import Document; Document
  File "/usr/local/lib/python3.5/dist-packages/bokeh/document/__init__.py", line 7, in <module>
    from .document import Document ; Document
  File "/usr/local/lib/python3.5/dist-packages/bokeh/document/document.py", line 33, in <module>
    from ..core.json_encoder import serialize_json
  File "/usr/local/lib/python3.5/dist-packages/bokeh/core/json_encoder.py", line 45, in <module>
    import numpy as np
  File "/usr/local/lib/python3.5/dist-packages/numpy/__init__.py", line 142, in <module>
    from . import add_newdocs
  File "/usr/local/lib/python3.5/dist-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/local/lib/python3.5/dist-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/usr/local/lib/python3.5/dist-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/usr/local/lib/python3.5/dist-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

また調べると、libatlas-base-devをインストールするとよいと、Stack Overflowで見つける

sudo apt-get install libatlas-base-dev

パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
  gfortran gfortran-6 libatlas-dev libatlas3-base libblas-dev libgfortran-6-dev
提案パッケージ:
  gfortran-doc gfortran-6-doc libgfortran3-dbg libcoarrays-dev libblas-doc liblapack-doc
  liblapack-dev liblapack-doc-man
以下のパッケージが新たにインストールされます:
  gfortran gfortran-6 libatlas-base-dev libatlas-dev libatlas3-base libblas-dev libgfortran-6-dev
アップグレード: 0 新規インストール: 7 削除: 0 保留: 113 
10.2 MB のアーカイブを取得する必要があります
この操作後に追加で 48.4 MB のディスク容量が消費されます
続行しますか? [Y/n] y
取得:1 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian stretch/main armhf libgfortran-6-dev armhf 6.3.0-18+rpi1+deb9u1 [199 kB]
取得:2 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian stretch/main armhf gfortran-6 armhf 6.3.0-18+rpi1+deb9u1 [5,421 kB]
取得:3 http://mirrordirector.raspbian.org/raspbian stretch/main armhf gfortran armhf 4:6.3.0-4 [1,352 B]
取得:4 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian stretch/main armhf libatlas3-base armhf 3.10.3-1+rpi1 [1,920 kB]
取得:5 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian stretch/main armhf libblas-dev armhf 3.7.0-2 [114 kB]
取得:6 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian stretch/main armhf libatlas-dev armhf 3.10.3-1+rpi1 [65.9 kB]
取得:7 http://ftp.jaist.ac.jp/pub/Linux/raspbian-archive/raspbian stretch/main armhf libatlas-base-dev armhf 3.10.3-1+rpi1 [2,528 kB]
10.2 MB  42 で取得しました (241 kB/s)                                                           
以前に未選択のパッケージ libgfortran-6-dev:armhf を選択しています
(データベースを読み込んでいます ... 現在 127645 個のファイルとディレクトリがインストールされています)
.../0-libgfortran-6-dev_6.3.0-18+rpi1+deb9u1_armhf.deb を展開する準備をしています ...
libgfortran-6-dev:armhf (6.3.0-18+rpi1+deb9u1) を展開しています...
以前に未選択のパッケージ gfortran-6 を選択しています
.../1-gfortran-6_6.3.0-18+rpi1+deb9u1_armhf.deb を展開する準備をしています ...
gfortran-6 (6.3.0-18+rpi1+deb9u1) を展開しています...
以前に未選択のパッケージ gfortran を選択しています
.../2-gfortran_4%3a6.3.0-4_armhf.deb を展開する準備をしています ...
gfortran (4:6.3.0-4) を展開しています...
以前に未選択のパッケージ libatlas3-base を選択しています
.../3-libatlas3-base_3.10.3-1+rpi1_armhf.deb を展開する準備をしています ...
libatlas3-base (3.10.3-1+rpi1) を展開しています...
以前に未選択のパッケージ libblas-dev を選択しています
.../4-libblas-dev_3.7.0-2_armhf.deb を展開する準備をしています ...
libblas-dev (3.7.0-2) を展開しています...
以前に未選択のパッケージ libatlas-dev を選択しています
.../5-libatlas-dev_3.10.3-1+rpi1_armhf.deb を展開する準備をしています ...
libatlas-dev (3.10.3-1+rpi1) を展開しています...
以前に未選択のパッケージ libatlas-base-dev を選択しています
.../6-libatlas-base-dev_3.10.3-1+rpi1_armhf.deb を展開する準備をしています ...
libatlas-base-dev (3.10.3-1+rpi1) を展開しています...
libatlas3-base (3.10.3-1+rpi1) を設定しています ...
update-alternatives: /usr/lib/libblas.so.3 (libblas.so.3) を提供するために自動モードで /usr/lib/atlas-base/atlas/libblas.so.3 を使います
update-alternatives: /usr/lib/liblapack.so.3 (liblapack.so.3) を提供するために自動モードで /usr/lib/atlas-base/atlas/liblapack.so.3 を使います
libgfortran-6-dev:armhf (6.3.0-18+rpi1+deb9u1) を設定しています ...
libc-bin (2.24-11+deb9u1) のトリガを処理しています ...
man-db (2.7.6.1-2) のトリガを処理しています ...
gfortran-6 (6.3.0-18+rpi1+deb9u1) を設定しています ...
gfortran (4:6.3.0-4) を設定しています ...
update-alternatives: /usr/bin/f95 (f95) を提供するために自動モードで /usr/bin/gfortran を使います
update-alternatives: /usr/bin/f77 (f77) を提供するために自動モードで /usr/bin/gfortran を使います
libblas-dev (3.7.0-2) を設定しています ...
update-alternatives: /usr/lib/libblas.so (libblas.so) を提供するために自動モードで /usr/lib/libblas/libblas.so を使います
libatlas-dev (3.10.3-1+rpi1) を設定しています ...
libatlas-base-dev (3.10.3-1+rpi1) を設定しています ...
update-alternatives: /usr/lib/libblas.so (libblas.so) を提供するために自動モードで /usr/lib/atlas-base/atlas/libblas.so を使います
update-alternatives: /usr/lib/liblapack.so (liblapack.so) を提供するために自動モードで /usr/lib/atlas-base/atlas/liblapack.so を使います

これでエラーは消えました

さいごに

エラーの原因はパッケージの依存関係のようです。同じような症状発生した方の参考になれば幸いです。

5
5
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
5
5