Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Keras if the required version of setuptools is older than default?

I'm using conda 4.4.9. I have already installed TensorFlow and I want to install Keras as well.

Then I tried to activate my virtual environment and install Keras as below:-

activate tensorflow_env_001
pip install --ignore-installed --upgrade keras

Then I got the following error message:

tensorflow 1.9.0 has requirement setuptools<=39.1.0, but you'll have setuptools 39.2.0 which is incompatible

That means my setuptools is too new. In fact, I can run the TensorFlow codes without any error. But I just can't install Keras. I tried to update setuptools but that had just made the situation worse, as setuptools now become 40.0.0.

If I run conda list, and I will see this:-

enter image description here

That means all TensorFlow, Keras and setuptools are here. But when I tried to import Keras in my Python code, I just got ModuleNotFoundError: No module named 'keras'.

How can I properly install Keras? Many thanks!!

like image 226
H42 Avatar asked Jul 25 '18 19:07

H42


People also ask

How do I install an older version of keras?

1) You can try pip install keras==[version number] --user to install a specific version of keras from pypi. this will downgrade the tensorflow and keras version to 1.11. 0 and 2.1. 6-tf respectively.

Can I install keras without TensorFlow?

The recommended approach as of now and in the foreseeable future is to use the keras inside Tensorflow , as even Francois Chollet, the creator of Keras mentions this. Practically, you have to install only TensorFlow, and make all your imports like from tensorflow. keras.


2 Answers

Try to remove the env

conda remove --name ENVNAME --all

Then create a new one but first upgrade the pip version

python -m pip install --upgrade pip

and then install tensorflow:

pip install --ignore-installed --upgrade tensorflow==1.9.0

It will automatically get (downgrade) your version of setuptools

    #
    # Name                    Version                   Build  Channel
    .......
    python                    3.5.6                he025d50_0
    setuptools                39.1.0                   pypi_0    pypi
    six                       1.12.0                   pypi_0    pypi
    tensorboard               1.9.0                    pypi_0    pypi
    tensorflow                1.9.0                    pypi_0    pypi
    termcolor                 1.1.0                    pypi_0    pypi
    .....
like image 30
J.Gastón T.I. Avatar answered Jan 04 '23 04:01

J.Gastón T.I.


tensorflow 1.9.0 has requirement setuptools<=39.1.0, but you'll have setuptools 39.2.0 which is incompatible

i got same error.To downgrade your setuptools version you can use

pip install setuptools==39.1.0

hope this helps further for keras installations.

like image 161
Adarsh Patel Avatar answered Jan 04 '23 05:01

Adarsh Patel