6

I've been trying to install Tensorflow 2.0 in Anaconda.

So far, tensorflow works fine (i can use the library in my code), but when i'm installing it, it says "installing version: 2.0", then i get version 1.15 instead.

The whole package results updatable (since versione 2.0 does exist and should be available), but even if i try to update it, i keep getting 1.15, which gets back to updatable, and i get back into the loop.

I tried both from the Anaconda Navigator interface and the prompt using conda update tensorflow, without any success.

Here's there is the link package: tensorflow 2.0 Anaconda

How can i solve the problem?

EDIT :

I successfully installed TensorFlow 2.0 using conda install -c anaconda tensorflow. Then i got back into Anaconda Navigator and i tried to install Keras 2.2.4.

Looking at the installed packages, seems that installing Keras overwrites the version 2.0 of TensorFlow with the 1.15, am i wrong? Is this a bug?

Here's the image: Keras install

Mattia Surricchio
  • 1,362
  • 2
  • 21
  • 49
  • While I am late to the party, would you happen to have the contents of the environment (using something like `conda list`) ? – AMC Apr 29 '20 at 02:32

5 Answers5

10

Another alternative is to install Tensorflow with Miniconda.

I simply have used Miniconda3 for windows and I was able to install multiple versions of Tensorflow on different environment respectively.

Example 1

// create a new environment
conda create --name workflowone

// activate environment
conda activate workflowone

// Install desired package
conda install tensorflow=1.15

// deactivate environment
conda deactivate

Example 2

// create a new environment
conda create --name workflowtwo

// activate environment
conda activate workflowtwo

// Install desired package
conda install tensorflow  // If you do not specify the version, you will download the latest version of Tensorflow

// deactivate environment
conda deactivate
Niyongabo Eric
  • 1,333
  • 18
  • 21
5

conda install -c anaconda tensorflow-gpu

or

conda install -c anaconda tensorflow

Look for these:


Tip: completely shred any file w/ name substring "keras" and "tensorflow" in your Anaconda environment before installing - else stuff is likely to break.

  1. Navigate to your site-packages
  2. Search **keras** --> delete all results
  3. Search **tensorflow** --> delete all results

Above should work even better from the environment's root folder (e.g. envs/tf2_env) -- the idea is, Anaconda caches whatever it's already installed, so if it isn't completely removed, you may find trouble getting latest vers of packages.


Related Q's answered in comments:

  1. Why is conda reverting TF 2 to TF 1.15.0 when I try installing Keras 2.2.4?

    • TF2's only compatible w/ Keras 2.2.5+, so conda is taking care of compatibility
  2. Why are some from keras imports no longer working and need from tensorflow.keras?

    • from keras is very different from from tensorflow.keras, implementation-wise. from keras is backend-neutral, whereas tf.keras is more tightly integrated w/ TF. There can also be significant performance differences. TF2 and onward, tf.keras is preferable, and development will proceed along it, as noted by F. Chollet
    • Also beware of tf.python.keras
OverLordGoldDragon
  • 1
  • 9
  • 53
  • 101
  • Do i have to install both tensorflow and tensorflow-gpu or one is enough? Is it ok if i remove the already installed packages from the anaconda navigator or i must delete by hand the files (using explorer)? – Mattia Surricchio Nov 19 '19 at 23:20
  • @MattiaSurricchio Explorer's the best bet - and only _one_ is enough – OverLordGoldDragon Nov 19 '19 at 23:33
  • Anyway i updated the question, seems there could be a possible bug in the installation of the packages. Seems that keras overwrites the tensorflow version – Mattia Surricchio Nov 19 '19 at 23:39
  • 1
    @MattiaSurricchio Not a bug; TF2's only compatible w/ Keras 2.2.5+, so conda is taking care of compatibility here – OverLordGoldDragon Nov 19 '19 at 23:44
  • Maybe i'm missing something, is Keras now embedded inside the TensorFlow package? I've installed it correctly and it works, but i had to rewrite my import, for example ``from tensorflow.keras import Sequential``, while before i was using just ``from keras import Sequential``. This make me think that now Keras comes with TensorFlow 2.0 and i dont need to install it as a separate package, am i wrong? – Mattia Surricchio Nov 19 '19 at 23:52
  • @MattiaSurricchio One'd be surprised, but `from keras` is very different from `from tensorflow.keras`, implementation-wise, and has been since TF1; just run `help(Adam)` for both to see their source path differences. `from keras` is backend-neutral, whereas `tf.keras` is more tightly integrated w/ TF. There can also be [significant performance differences](https://stackoverflow.com/questions/58441514/why-is-tensorflow-2-much-slower-than-tensorflow-1?noredirect=1&lq=1). But yes, TF2 and onward, `tf.keras` is preferable, and development will proceed along it – OverLordGoldDragon Nov 20 '19 at 00:09
-1

In my case, this solved the problem:

pip3 install tensorflow==2.0.0a0

or even:

pip3 install tensorflow --upgrade
razimbres
  • 4,715
  • 5
  • 23
  • 50
  • 3
    I avoided using pip since i read that could lead to some "compatibility" problems if matched with anaconda. Is it possible to "stay" inside the anaconda framework? – Mattia Surricchio Nov 19 '19 at 22:55
  • 1
    The OP is explicitly asking for a conda solution. Mattia I'd suggest you to don't mix conda and pip in particular if you are going to use env in production. Eventually you can build a conda package from pip – rpanai Nov 19 '19 at 23:41
-1

I struggled with this very problem this week, and found an EASY solution:
Go to Anaconda Navigator (make sure you have the latest update), click on 'Environments' and select 'not installed' from the dropdown menu. In the search field type "tensorflow". Click the checkbox for 'tensorflow' but NOT also for 'keras'. Click 'apply' and it will install 2.0, as well as keras. Then all you have to do to use them is:

import tensorflow as tf

from tensorflow import keras

If you had previously installed the unintended versions, delete all of them first, then do the above.

-1

Solved

$ conda update --prefix # first step
$ conda 4.8.2  # lates Anaconda

Open Anaconda --> Create environment--> Choose python V3.6 --> Search/select TensorFlow 2.0 == Anaconda will upgrade with dependencies

Latest Jupyter in this new environment

$ jupyter --version # latest jupyter notebook version created with pyton 3.6
jupyter core     : 4.6.1
jupyter-notebook : 6.0.0

Upgrade tf