Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UsageError: Line magic function `%tensorflow_version` not found

I've got TensorFlow installed on my machine however I'm keep getting the error: UsageError: Line magic function `%tensorflow_version` not found.

Any ideas as to why this is? The code I ran is below (Jupyter Notebook)

%tensorflow_version 1.x
import tensorflow as tf
print(tf.__version__)
like image 602
softmax55 Avatar asked Dec 28 '19 19:12

softmax55


People also ask

How do I find the version of TensorFlow in Colab?

To check your TensorFlow version in your Jupyter Notebook such as Google's Colab, use the following two commands: import tensorflow as tf This imports the TensorFlow library and stores it in the variable named tf . print(tf. __version__) This prints the installed TensorFlow version number in the format x.y.z .


2 Answers

Jupyter notebook comes with a set of magic functions, but %tensorflow_version is not one of them. The magic command

%tensorflow_version X.X

is only available in Google Colab notebooks, not Jupyter notebooks.

like image 138
James Avatar answered Nov 09 '22 03:11

James


This code

%tensorflow_version 1.x

...is a "magic" command ("magic spell") in Google Colab that instructs the Colab environment to use the newest stable release of Tensorflow version 1. For you to get the code to work on your own Jupyter notebook, you'll need to install Tensorflow locally. There are a few ways:

command line, installing a particular version:

pip install tensorflow==1.15.0

or in your Jupyter notebook, itself:

import sys 
!{sys.executable} -m pip install tensorflow==1.15.0
# !{sys.executable} -m pip install --user tensorflow==1.15.0. # you may need '--user' based on your environment
like image 28
Ryan Loggerythm Avatar answered Nov 09 '22 03:11

Ryan Loggerythm