Cannot import keras after installation
<p>I'm trying to setup <code>keras</code> deep learning library for <code>Python3.5</code> on Ubuntu 16.04 LTS and use <code>Tensorflow</code> as a backend. I have <code>Python2.7</code> and <code>Python3.5</code> installed. I have installed <code>Anaconda</code> and with help of it  <code>Tensorflow</code>, <code>numpy</code>, <code>scipy</code>, <code>pyyaml</code>. Afterwards I have installed <code>keras</code> with command</p>

<blockquote>
  <p>sudo python setup.py install</p>
</blockquote>

<p>Although I can see <code>/usr/local/lib/python3.5/dist-packages/Keras-1.1.0-py3.5.egg</code> directory, I cannot use <code>keras</code> library. When I try to import it in python it says</p>

<blockquote>
  <p>ImportError: No module named 'keras'</p>
</blockquote>

<p>I have tried to install <code>keras</code> using<code>pip3</code>, but got the same result. </p>

<p>What am I doing wrong? Any Ideas?</p>

<h2>Diagnose</h2>

<p>If you have <code>pip</code> installed (you should have it until you use Python 3.5), list the installed Python packages, like this:</p>

<pre><code>$ pip list | grep -i keras
Keras (1.1.0)
</code></pre>

<p>If you donât see Keras, it means that the previous installation failed or is incomplete (this lib has this dependancies: numpy (1.11.2), PyYAML (3.12), scipy (0.18.1), six (1.10.0), and Theano (0.8.2).)</p>

<p>Consult the <code>pip.log</code> to see whatâs wrong.</p>

<p>You can also display your Python path like this:</p>

<pre><code>$ python3 -c 'import sys, pprint; pprint.pprint(sys.path)'
['',
 '/Library/Frameworks/Python.framework/Versions/3.5/lib/python35.zip',
 '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5',
 '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin',
 '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload',
 '/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages']
</code></pre>

<p>Make sure the Keras library appears in the <code>/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages</code> path (the path is different on Ubuntu).</p>

<p>If not, try do uninstall it, and retry installation:</p>

<pre><code>$ pip uninstall Keras
</code></pre>

<h2>Use a virtualenv</h2>

<p>Itâs a bad idea to use and pollute your system-wide Python. I recommend using a virtualenv (see this <a href="http://docs.python-guide.org/en/latest/dev/virtualenvs/" rel="nofollow">guide</a>).</p>

<p>The best usage is to create a <code>virtualenv</code> directory (in your home, for instance), and store your virtualenvs in:</p>

<pre><code>cd virtualenv/
virtualenv -p python3.5 py-keras
source py-keras/bin/activate
pip install -q -U pip setuptools wheel
</code></pre>

<p>Then install Keras:</p>

<pre><code>pip install keras
</code></pre>

<p>You get:</p>

<pre><code>$ pip list
Keras (1.1.0)
numpy (1.11.2)
pip (8.1.2)
PyYAML (3.12)
scipy (0.18.1)
setuptools (28.3.0)
six (1.10.0)
Theano (0.8.2)
wheel (0.30.0a0)
</code></pre>

<p>But, you also need to install extra libraries, like Tensorflow:</p>

<pre><code>$ python -c "import keras"
Using TensorFlow backend.
Traceback (most recent call last):
  ...
ImportError: No module named 'tensorflow'
</code></pre>

<p>The installation guide of TesnsorFlow is here: <a href="https://www.tensorflow.org/versions/r0.11/get_started/os_setup.html#pip-installation" rel="nofollow">https://www.tensorflow.org/versions/r0.11/get_started/os_setup.html#pip-installation</a></p>

python ubuntu tensorflow anaconda keras