LoginSignup
3
0

More than 1 year has passed since last update.

ラズパイ環境でinvestpyをpip installしようとしたら“error command gcc failed with exit status 1”のエラーで詰まったときの話

Posted at

0.前置き

株や為替のデータを取得するためのpythonライブラリinvestpyを使用するため、ラズパイ上で動作しているRasbianOSでpip installを実施たところ、“error command gcc failed with exit status 1”"ERROR: Command errored out with exit status 1" というエラーでインストールできず、詰まってしましました。

色々と試してみて、なんとか解決できたので、その際に実施したことをまとめます。

1.環境

  • raspberry Pi3B+:Raspbian GNU/Linux 10 (buster)
  • python 3.10.1
  • pip 21.3.1
  • gcc version 8.3.0 (Raspbian 8.3.0-6+rpi1)

2.解決に繋がりそうなこと要約

色々と試しましたが、以下の項目がキーとなっていそうです。順番に試していただいて、解決できるかを試してください。

  1. pipの存在確認&アップデート
  2. gccの存在確認&アップデート
  3. build-essentialの存在確認&インストール
  4. python3-devの存在確認&インストール
  5. libffi、 libxslt、opensslの存在確認&インストール

なお、今回私の場合は、1~4はapt upgradeで一括でアップデートし、その後libxsltライブラリのインストール(アップデート)で無事解決しました。

3.“error command gcc failed with exit status 1”の解決

最初に出たエラーがこれでした。pip installでインストールするライブラリのコンパイルに失敗しているエラーなので、以下を実施すると解決できるかもしれません。

  • pipのアップデート
    • pip install -U pip
  • gccのアップデート
    • sudo apt update
    • sudo apt upgrade gcc
  • build-essentialのインストール
    • sudo apt install build-essential
  • python3-devのインストール
    • sudo apt install python3-dev

4. "ERROR: Command errored out with exit status 1:の解決

上記gccライブラリ関係のエラーは解決できましたが、まだexit status 1のエラーが表示されていました。
ライブラリのコンパイルに必要なツールがまだ足りていない可能性があり、利用頻度の高い3つのライブラリをインストールしました。

  • libffi、 libxslt、openssのインストール
    • sudo apt install libxslt-dev libffi-dev libssl-dev

上記ライブラリの中で、私の場合はlibxslt-devが不足していたようです。このライブラリに関連する各種ソフトウェアがインストールされ、再度investpyのインストールを試みると、いかのように無事インストールすることができました。

terminal
    root@raspberrypi:/home/pi# pip install investpy
    WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
    Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
    To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
    Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
    Collecting investpy
      Using cached https://www.piwheels.org/simple/investpy/investpy-1.0.7-py3-none-any.whl (4.5 MB)
    Collecting lxml>=4.4.1
      Using cached lxml-4.7.1.tar.gz (3.2 MB)
      Preparing metadata (setup.py) ... done
    Requirement already satisfied: Unidecode>=1.1.1 in /usr/local/lib/python3.10/site-packages (from investpy) (1.3.2)
    Requirement already satisfied: requests>=2.22.0 in /usr/local/lib/python3.10/site-packages (from investpy) (2.27.1)
    Requirement already satisfied: pandas>=0.25.1 in /usr/local/lib/python3.10/site-packages (from investpy) (1.3.5)
    Requirement already satisfied: pytz>=2019.3 in /usr/local/lib/python3.10/site-packages (from investpy) (2021.3)
    Requirement already satisfied: setuptools>=41.2.0 in /usr/local/lib/python3.10/site-packages (from investpy) (58.1.0)
    Requirement already satisfied: numpy>=1.17.2 in /usr/local/lib/python3.10/site-packages (from investpy) (1.22.0)
    Requirement already satisfied: python-dateutil>=2.7.3 in /usr/local/lib/python3.10/site-packages (from pandas>=0.25.1->investpy) (2.8.2)
    Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/site-packages (from requests>=2.22.0->investpy) (1.26.7)
    Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/site-packages (from requests>=2.22.0->investpy) (2021.10.8)
    Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/site-packages (from requests>=2.22.0->investpy) (3.3)
    Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.10/site-packages (from requests>=2.22.0->investpy) (2.0.10)
    Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/site-packages (from python-dateutil>=2.7.3->pandas>=0.25.1->investpy) (1.16.0)
    Using legacy 'setup.py install' for lxml, since package 'wheel' is not installed.
    Installing collected packages: lxml, investpy
        Running setup.py install for lxml ... done
    Successfully installed investpy-1.0.7 lxml-4.7.1

5. そういえば...

一旦解決したあと、改めてエラーログを確認してみると、"Error: Please make sure the libxml2 and libxslt development packages are installed."と書かれている箇所を見つけました。やはりlibxsltあたりに問題があったようですね。

image.png

以上、どなたかのお役に立てば幸いです。

3
0
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
3
0