[PYTHON] Theano installation notes

Thing you want to do

I want to create an environment where theano can be used with pyenv

OS: Ubuntu 16.04.1 LTS

Where it got stuck

Use pyenv normally

pyenv install 2.7.6
pyenv shell 2.7.6
pip install Theano
python -c "import theano"

If you do

.pyenv/versions/2.7.10/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
.pyenv/versions/2.7.10/lib/libpython2.7.a: error adding symbols: Bad value

Error. .. ..

Cause

If you check with stackoverflow,

Error importing Theano - Stack Overflow here,

You didn't build correctly python. It wasn't compiled with the -fPIC parameter. Look at how to compile python with a shared library.

I'm not sure, but there is no shared library.

Solution

You have to add the option --enable-shared when installing python. The installation method with pyenv was written at the bottom of Home · yyuu / pyenv Wiki · GitHub.

env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.5.0

You can change it if you want to install the version. For the time being, python -c" import theano " passed. Then python -c" import theano; theano.test () " Then, if there is no module called nose and nose_parameterized, The official Installing Theano --Theano 0.8.2 documentation also stated that these two should be included when testing. pip install nose nose-parameterized

For the time being, I passed the test. (Although various warnings came out.)

Summary

When using pyenv to insert theano

env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install x.x.x
pyenv shell x.x.x
pip install nose nose_parameterized theano
python -c "import theano; theano.test()

That's it for the time being. I haven't confirmed the GPU related items yet, so I will add it if there is a problem.

Recommended Posts

Theano installation notes
Mecab installation notes
pyenv installation notes
Hydrogen installation notes
Python3.4 installation notes
Cabocha installation notes
Arch Linux installation notes
Installation notes for TensorFlow for Windows
Homebrew and Pycharm installation instructions notes
JetBrains_Learning Notes_003
Django installation
Cuda installation
boto3 installation
SQLAlchemy notes
Pythia Installation
pyenv notes
Docker installation
Volatility installation
Python installation
pip installation
SQL notes
Sphinx installation
Pandas notes
Sphinx notes
django notes
Jupyter_Learning Notes_000
InstantOS 1 installation
Jupyter installation
Python installation
pip installation
Kivy installation
ChaSen installation
Backtrader installation
GPD P2 Max Ubuntu Mate installation notes
pip installation
Django notes