Unable to import tflearn in google colab

386 views
Skip to first unread message

Srikanth KS

unread,
Sep 3, 2020, 5:43:57 AM9/3/20
to Discuss
Hi, 
I am trying to learn tensor flow's CNN using tflearn. I am able to get my MNIST dataset compiled and model trained in spyder python on my computer however when i try to do the same on google colab i get an error 
import tensorflow as tf
print(tf.__version__)
2.3.0 
!pip install tflearn
import tflearn  
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-3-9d7ed441cee1> in <module>() ----> 1 import tflearn
2 frames
/usr/local/lib/python3.6/dist-packages/tflearn/variables.py in <module>() 5 import tflearn 6 ----> 7 from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scope 8 from tensorflow.python.framework import ops 9 from tensorflow.python.ops import variable_scope ModuleNotFoundError: No module named 'tensorflow.contrib' --------------------------------------------------------------------------- NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt. To view examples of installing some common dependencies, click the "Open Examples" button below. ---------------------------------------------------------------------------  

muhammad harris

unread,
Sep 3, 2020, 5:55:17 AM9/3/20
to Srikanth KS, Discuss
contrib is no longer available in TF 2.0. you may want to downgrade to tf 1.x to use the above library. 
For colab there's an easier way to do so:
1. Make sure to restart the runtime kernel
2. add %tensorflow_version 1.x at the top cells before importing tensorflow
3. check version print(tf.__version__) this should reflect 1.x versions

hope this helps :)

--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/9f95584f-4045-41c9-b6f3-ff70000e8af9n%40tensorflow.org.

Srikanth KS

unread,
Sep 3, 2020, 10:51:40 PM9/3/20
to muhammad harris, Discuss
Hi Harris, 
Yes it worked like a charm thank you so much you made my day
Regards
srikanth
Reply all
Reply to author
Forward
0 new messages