ゆるふわめも

東京か京都にいます。

エラー解決:auto-sklearnやSMAC3.0のインストールがpyrfrのエラーで終了する

pyrfr関係のエラーは探すとたくさん。はまってしまって時間が持ってかれた。

pyrfrはSMACと言うアルゴリズムで使用するRandomForestで使用するライブラリ。

エラー内容

XXXXX@XXXXX:~/SMAC3$ cat requirements.txt | xargs -n 1 -L 1 pip install

Requirement already satisfied: setuptools in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: numpy>=1.7.1 in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: scipy>=0.18.1 in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: numpy>=1.8.2 in /usr/local/lib/python2.7/dist-packages (from scipy>=0.18.1)
Requirement already satisfied: six in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: psutil in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: pynisher>=0.4.1 in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: psutil in /usr/local/lib/python2.7/dist-packages (from pynisher>=0.4.1)
Requirement already satisfied: setuptools in /usr/local/lib/python2.7/dist-packages (from pynisher>=0.4.1)
Requirement already satisfied: docutils>=0.3 in /usr/local/lib/python2.7/dist-packages (from pynisher>=0.4.1)
Requirement already satisfied: ConfigSpace>=0.3.2 in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: pyparsing in /usr/lib/python2.7/dist-packages (from ConfigSpace>=0.3.2)
Requirement already satisfied: argparse in /usr/lib/python2.7 (from ConfigSpace>=0.3.2)
Requirement already satisfied: numpy in /usr/local/lib/python2.7/dist-packages (from ConfigSpace>=0.3.2)
Requirement already satisfied: typing in /usr/local/lib/python2.7/dist-packages (from ConfigSpace>=0.3.2)
Requirement already satisfied: scikit-learn in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: typing in /usr/local/lib/python2.7/dist-packages
Collecting pyrfr>=0.4.0
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Using cached pyrfr-0.4.0.tar.gz
Building wheels for collected packages: pyrfr
  Running setup.py bdist_wheel for pyrfr ... error
  Complete output from command /usr/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-JRv08f/pyrfr/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpYpeMtzpip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  creating build/lib.linux-x86_64-2.7/pyrfr
  copying pyrfr/__init__.py -> build/lib.linux-x86_64-2.7/pyrfr
  running build_ext
  building '_regression' extension
  swigging pyrfr/regression.i to pyrfr/regression_wrap.cpp
  swig -python -c++ -I${CMAKE_SOURCE_DIR}/include -I./include -o pyrfr/regression_wrap.cpp pyrfr/regression.i
  ./include/rfr/trees/binary_fanova_tree.hpp:329: Error: Syntax error in input(3).
  error: command 'swig' failed with exit status 1

環境

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"

解決法

swig2.0.0 から swig3.0へ。

$ apt-get remove swig
$ apt-get install swig3.0
$ ln -s /usr/bin/swig3.0 /usr/bin/swig

pyrfr関連のエラー

同じエラーで止まっている方もいるけど、おそらくswigが原因だと思う。

pyrfrはインストールできるけれど、pyrfrの訓練(rf.model.fit)で止まるケースは rng オプションがバージョンによって扱いが変わっていることが原因。以下の最後の方を参照。

paper.hatenadiary.jp