PeterBe
PeterBe

Reputation: 852

Keras for Python can't be installed using Anaconda

I would like to install the libaray Keras for machine learning in Python (https://keras.io/). I use Anaconda (as an Administrator) and I tried the following command.

(base) C:\Users\wi9632>conda install keras

And here is the output with the error message:

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: -
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - keras -> python[version='>=3.5,<3.6.0a0|>=3.6,<3.7.0a0']

Your python: python=3.8.5

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

Can you tell me what I have to do in order to install Keras? If I understand correctly, the version of my Python environment is to new? I'd appreciate every comment.

Does nobody have an idea what I can do? I'd be quite happy about it.

Update: I tried it by using the command:

conda install -c conda-forge keras (see https://anaconda.org/conda-forge/keras) and I tried to install the packages by using the GUI of Anaconda. Both yielded the same error message.

Upvotes: 1

Views: 9473

Answers (1)

Alperino
Alperino

Reputation: 568

The problem seems to be with conda rather than with keras, see here. Using pip instead of conda might resolve your problem.

However, I'd discourage using keras anyway as now using tf.keras is the recommended way of working with Keras, see here:

Keras 2.3.0 is the first release of multi-backend Keras that supports TensorFlow 2.0. It maintains compatibility with TensorFlow 1.14, 1.13, as well as Theano and CNTK.

This release brings the API in sync with the tf.keras API as of TensorFlow 2.0. However note that it does not support most TensorFlow 2.0 features, in particular eager execution. If you need these features, use tf.keras.

This is also the last major release of multi-backend Keras. Going forward, we recommend that users consider switching their Keras code to tf.keras in TensorFlow 2.0.

So if conda install tensorflow works for you, just replace any appearance of keras with tf.keras in your code. This way, there is no need to install keras separately.

Upvotes: 3

Related Questions