I started a Colab notebook from scratch and imported TensorFlow, expecting to get version 2. Somehow I get this message:

The default version of TensorFlow in Colab will soon switch to TensorFlow 2.x.We recommend you upgrade now or ensure your notebook will continue to use TensorFlow 1.x via the %tensorflow_version 1.x magic: more info.

Too bad it does not automatically switch to TF2 yet. So in order to get the right version, I have to prepend my import with that special flag:

%tensorflow_version 2.x
import tensorflow as tf

Upon running the cell again, I get:

TensorFlow is already loaded. Please restart the runtime to change versions.

So I restart the runtime

And run the cell again. This time it loads the right version: