LoginSignup
3
0

More than 3 years have passed since last update.

[python] macOS mojaveでtheanoを使うモジュールでエラーが出る問題を解決する

Last updated at Posted at 2019-06-13

Pythonでpymc3などを使うときにtheanoが内部でインポートされるが,その際にmacOS mojave以降で以下のようなエラーがimport時に出ることがある.

import pymc3 as pm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jotaro/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/pymc3/__init__.py", line 5, in <module>
    from .distributions import *
  File "/Users/jotaro/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/pymc3/distributions/__init__.py", line 1, in <module>
    from . import timeseries
  File "/Users/jotaro/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/pymc3/distributions/timeseries.py", line 1, in <module>
    import theano.tensor as tt
  File "/Users/jotaro/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/theano/__init__.py", line 110, in <module>
    from theano.compile import (
  File "/Users/jotaro/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/theano/compile/__init__.py", line 12, in <module>
    from theano.compile.mode import *
  File "/Users/jotaro/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/theano/compile/mode.py", line 11, in <module>
    import theano.gof.vm
  File "/Users/jotaro/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/theano/gof/vm.py", line 674, in <module>
    from . import lazylinker_c
  File "/Users/jotaro/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/theano/gof/lazylinker_c.py", line 140, in <module>
    preargs=args)
  File "/Users/jotaro/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/theano/gof/cmodule.py", line 2391, in compile_str
    (status, compile_stderr.replace('\n', '. ')))
Exception: Compilation failed (return status=1): In file included from /Users/jotaro/.theano/compiledir_Darwin-18.2.0-x86_64-i386-64bit-i386-3.6.8-64/lazylinker_ext/mod.cpp:1:. In file included from /Users/jotaro/.pyenv/versions/anaconda3-5.0.1/include/python3.6m/Python.h:25:. /Users/jotaro/.pyenv/versions/anaconda3-5.0.1/bin/../include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found. #include_next <stdio.h>.

原因・解決法

macOS mojaveからヘッダファイルがデフォルトで/usr/includeに置かれていないのが原因.
以下のスクリプトを実行すると,.pkgをインストールするダイアログとともにヘッダファイルが当該ディレクトリに配置されるようになる.


open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
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