Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix 'No module named 'tensorflow.contrib' for python project?

Tags:

tensorflow

I found a chatbot program in github and wanted to run this program for my better understanding. But every time I try to run this program, it says

No module named 'tensorflow.contrib'

What should I do to fix this error?

like image 229
Sujan Bal Avatar asked Mar 23 '19 07:03

Sujan Bal


People also ask

How do I fix No module named tensorflow error?

The Python "ModuleNotFoundError: No module named 'tensorflow'" occurs when we forget to install the tensorflow module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install tensorflow command.

What is tensorflow contrib?

TensorFlow's high-level machine learning API (tf. contrib. learn) makes it easy to configure, train, and evaluate a variety of machine learning models.

When was tensorflow contrib removed?

contrib was removed in version 1.14 or 1.15.


1 Answers

Probably the code you found was written in TensorFlow 1.x, but you have TensorFlow 2.x installed. Instead of downgrading TensorFlow, the compatibility module can be used:

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

Source:https://www.tensorflow.org/guide/migrate

like image 123
Yusufmet Avatar answered Nov 01 '22 10:11

Yusufmet