56518


以下のようなエラーが出ました。  
原因がわからないのですが、どのようにしたら解決するでしょうか。

よろしくお願い致します。

[code]

    Python 3.6.4 (default, Jul  9 2019, 13:06:04) 
    [GCC 7.4.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    import keras
    Using Theano backend.
    
    You can find the C code in this temporary file: /tmp/theano_compilation_error_0rx2eexr
    Traceback (most recent call last):
      File "/home/iota/.pyenv/versions/3.6.4/lib/python3.6/site-packages/theano/gof/lazylinker_c.py", line 81, in <module>
        actual_version, force_compile, _need_reload))
    ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None. Extra debug information: force_compile=False, _need_reload=True
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/iota/.pyenv/versions/3.6.4/lib/python3.6/site-packages/theano/gof/lazylinker_c.py", line 105, in <module>
        actual_version, force_compile, _need_reload))
    ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None. Extra debug information: force_compile=False, _need_reload=True
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/iota/.pyenv/versions/3.6.4/lib/python3.6/site-packages/keras/__init__.py", line 2, in <module>
        from . import backend
      File "/home/iota/.pyenv/versions/3.6.4/lib/python3.6/site-packages/keras/backend/__init__.py", line 61, in <module>
        from .theano_backend import *
      File "/home/iota/.pyenv/versions/3.6.4/lib/python3.6/site-packages/keras/backend/theano_backend.py", line 1, in <module>
        import theano
      File "/home/iota/.pyenv/versions/3.6.4/lib/python3.6/site-packages/theano/__init__.py", line 110, in <module>
        from theano.compile import (
      File "/home/iota/.pyenv/versions/3.6.4/lib/python3.6/site-packages/theano/compile/__init__.py", line 12, in <module>
        from theano.compile.mode import *
      File "/home/iota/.pyenv/versions/3.6.4/lib/python3.6/site-packages/theano/compile/mode.py", line 11, in <module>
        import theano.gof.vm
      File "/home/iota/.pyenv/versions/3.6.4/lib/python3.6/site-packages/theano/gof/vm.py", line 674, in <module>
        from . import lazylinker_c
      File "/home/iota/.pyenv/versions/3.6.4/lib/python3.6/site-packages/theano/gof/lazylinker_c.py", line 140, in <module>
        preargs=args)
      File "/home/iota/.pyenv/versions/3.6.4/lib/python3.6/site-packages/theano/gof/cmodule.py", line 2396, in compile_str
        (status, compile_stderr.replace('\n', '. ')))
    Exception: Compilation failed (return status=1): /usr/bin/ld: /home/iota/.pyenv/versions/3.6.4/lib/libpython3.6m.a(ceval.o): relocation R_X86_64_PC32 against symbol `_Py_NoneStruct' can not be used when making a shared object。 -fPIC を付けて再コンパイルしてください。. /usr/bin/ld: 最終リンクに失敗しました: 不正な値です. collect2: error: ld returned 1 exit status. 
    
[/code]


CC BY-SA 4.0
2019-07-09T07:15:17.420
56511
2019-07-09T11:40:20.280
2019-07-09T11:21:46.023
3060
27060
question
python python3
-fPIC を付けて再コンパイルしてください。. /usr/bin/ld: 最終リンクに失敗しました: 不正な値です. collect2: error: ld returned 1 exit status. のエラー


同様のエラーメッセージが出る例を見つけました（これはpyenv上のpysideですが）。

[Install pyside on Ubuntu 17.04 using pyenv : recompile with -fPIC · Issue #69
· pyside/pyside-setup](https://github.com/pyside/pyside-setup/issues/69)

そこで、[この問題を解決したコメント](https://github.com/pyside/pyside-
setup/issues/69#issuecomment-300410987)を参考に、以下のようにpyenvを利用して `--enable-shared`
フラグ付きでPythonをインストールしてみてください。

[code]

    $ PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.6.4
    $ pyenv local 3.6.4
    $ python3 -c 'import keras'
    
[/code]


CC BY-SA 4.0
2019-07-09T11:40:20.280
56518
2019-07-09T11:40:20.280
29826
56511
answer