I found ModuleNotFoundError: No module named 'tensorflow.contrib'

Viewed 3687

I try to run python on CMD. I import tensorflow.contrib in my python file.

import tensorflow.contrib.tensorrt as trt

when running on anaconda with this command.

python run_webcam.py --camera yoga.mp4

it show error:

  File "run_webcam.py", line 8, in <module>
    from tf_pose.estimator import TfPoseEstimator
  File "D:\work\pose estimation\tf-pose-estimation\tf_pose\__init__.py", line 5, in <module>
    from tf_pose.runner import infer, Estimator, get_estimator
  File "D:\work\pose estimation\tf-pose-estimation\tf_pose\runner.py", line 8, in <module>
    from tf_pose import eval
  File "D:\work\pose estimation\tf-pose-estimation\tf_pose\eval.py", line 13, in <module>
    from tf_pose.estimator import TfPoseEstimator
  File "D:\work\pose estimation\tf-pose-estimation\tf_pose\estimator.py", line 14, in <module>
    import tensorflow.contrib.tensorrt as trt
ModuleNotFoundError: No module named 'tensorflow.contrib'

I installed

pip install tensorflow

and change the version of tensorflow (Try to uninstall and install many version )

pip uninstall tensorflow
pip install tensorflow==...

but show the same error

1 Answers

Try replacing the following

import tensorflow.contrib.tensorrt as trt (used in ≤ TensorFlow 1.13.1 )

with

from tensorflow.python.compiler.tensorrt import trt(TensorFlow ≥ 1.14.1)

Credit to GitHub

Related