I'm trying to setup keras
deep learning library for Python3.5
on Ubuntu 16.04 LTS and use Tensorflow
as a backend. I have Python2.7
and Python3.5
installed. I have installed Anaconda
and with help of it Tensorflow
, numpy
, scipy
, pyyaml
. Afterwards I have installed keras
with command
sudo python setup.py install
Although I can see /usr/local/lib/python3.5/dist-packages/Keras-1.1.0-py3.5.egg
directory, I cannot use keras
library. When I try to import it in python it says
ImportError: No module named 'keras'
I have tried to install keras
usingpip3
, but got the same result.
What am I doing wrong? Any Ideas?
Firstly checked the list of installed Python packages by:
pip list | grep -i keras
If there is keras shown then install it by:
pip install keras --upgrade --log ./pip-keras.log
now check the log, if there is any pending dependencies are present, it will affect your installation. So remove dependencies and then again install it.
Diagnose
If you have
pip
installed (you should have it until you use Python 3.5), list the installed Python packages, like this: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).)
Consult the
pip.log
to see what’s wrong.You can also display your Python path like this:
Make sure the Keras library appears in the
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
path (the path is different on Ubuntu).If not, try do uninstall it, and retry installation:
Use a virtualenv
It’s a bad idea to use and pollute your system-wide Python. I recommend using a virtualenv (see this guide).
The best usage is to create a
virtualenv
directory (in your home, for instance), and store your virtualenvs in:Then install Keras:
You get:
But, you also need to install extra libraries, like Tensorflow:
The installation guide of TesnsorFlow is here: https://www.tensorflow.org/versions/r0.11/get_started/os_setup.html#pip-installation
Ran to the same issue, Assuming your using anaconda3 and your using a
venv
with>= python=3.6
:I had
pip
referring by default to pip3, which made me download the libs for python3. On the contrary I launched the shell aspython
(which opened python 2) and the library wasn't installed there obviously.Once I matched the names pip3 -> python3, pip -> python (2) all worked.