1
$\begingroup$

The question is already in the title: when installing tensorflow in command line (in a virtual environment or not...), it is always tensorflow version 1.14.0 which is going to be installed. Consequently, eager execution does not work, I get error messages ("Tensor Object has no attribute numpy..." etc.). However, the tensorflow documentation states that it should the recent tensorflow 2 version which is in fact the one I need. I would be glad to read your advice on this issue.

Kehrwert

$\endgroup$
  • 1
    $\begingroup$ pip install tensorflow=={version you like} $\endgroup$ – Leevo Jan 20 at 10:59
2
$\begingroup$

You install the version you want with:

pip install tensorflow=={version you want}

for example:

pip install tensorflow==2.0.0-beta1

If you are working in Google Colab it's even simpler, just type:

%tensorflow_version 2.x
import tensorflow as tf

and it will automatically import the latest version of TensorFlow 2.

Eager mode is default in TensorFlow 2.x, therefore you don't need to manually activate it. As soon as you import it it's immediately available.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Hi thanks. "pip install tensorflow==2.1.0-rc1" gives "no matching distribution for tensorflow==2.1.0-rc1". Moreover, the error message provides a list of versions which are recognized, for instance "2.0.0b1". However, if I install this one (which is seemingly successful, at least when considering the command line), then tf.__version__ still gives "1.4.0" (and tf has eager mode disabled etc.). It do not understand the problem. I have never had this issue until now where I am setting up my programming environment on a new computer under Ubuntu 18.04.3 LTS. I would be glad about further help. $\endgroup$ – Kehrwert Jan 21 at 7:43
  • $\begingroup$ usually, if a version is not available/correct, the error message displayed reports a list of the available versions for download. Can you see that? Alternatively, try a version that works, such as: pip install -q tensorflow==2.0.0-beta1 $\endgroup$ – Leevo Jan 21 at 8:33
  • $\begingroup$ Thank you, but this did not fix the issue. I'll report here once I've found a viable solution. $\endgroup$ – Kehrwert Jan 22 at 18:41
  • 1
    $\begingroup$ Hi, I found out in these days that older versions of pip won't let you install some package versions. I bought a new laptop few days ago, and I couldn't pip install tensorflow 2.1 until I upgraded pip to the latest version, then the installation started with no problem. $\endgroup$ – Leevo Apr 26 at 21:10
2
$\begingroup$

As has been mentioned, pip install and the appropriate TensorFlow version should do it for you.

However, if you are having trouble installing locally (maybe your Python version is not suited for TensorFlow v2.0), there is always the option of spinning up a Jupyter Notebook in Amazon SageMaker and running the notebook through the cloud.

For instance, using Python 3.6.5 (notebook specified as conda_tensorflow_p36), TensorFlow v2.0 can be installed as follows:

!pip install -q tensorflow==2.0.0-beta1

This could be an option if you don't wish to interfere with versions of Python installed locally.

| improve this answer | |
$\endgroup$
2
$\begingroup$

It could also be that your pip version is too old. You can upgrade to the latest pip with:

pip install --upgrade pip
| improve this answer | |
$\endgroup$
1
$\begingroup$

I finally got this to work just in a jupyter lab cell pip install tensorflow==2.1.0 dont do a !pip install tensorflow==2.1.0

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.