ModuleNotFoundError: No module named 'tensorflow.compat.v2'

See original GitHub issue

Description

I ran the following code in a Google Colab and get the error:

ModuleNotFoundError: No module named 'tensorflow.compat.v2'
!pip install -q tensorflow==1.13.1
!pip install -q tensorflow_probability==0.6.0
!pip install -q tensor2tensor==1.13.1
!pip install -q gym[atari]
!python -m tensor2tensor.rl.trainer_model_based \
  --loop_hparams_set=rlmb_base_stochastic_discrete \
  --loop_hparams=game=pong,epochs=1,ppo_epochs_num=0 \
  --output_dir=~/t2t_train/mb_sd_pong_random

$ pip freeze | grep tensor

mesh-tensorflow==0.1.16
tensor2tensor==1.13.1
tensorboard==1.13.1
tensorboard-plugin-wit==1.6.0.post3
tensorboardcolab==0.0.22
tensorflow==1.13.1
tensorflow-addons==0.8.3
tensorflow-datasets==2.1.0
tensorflow-estimator==1.13.0
tensorflow-gcs-config==2.2.0
tensorflow-hub==0.8.0
tensorflow-metadata==0.22.2
tensorflow-privacy==0.2.2
tensorflow-probability==0.6.0

$ python -V

Python 3.6.9

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

4reactions
Q-ihangcommented, Aug 27, 2020

On Colab, you can: 1.for the ‘tensorflow.compat.v2’ : try the command ‘%tensorflow_version 1.x’ 2.for ‘NoneType’ object has no attribute ‘Runner’ : a. If class ‘DQNLearner’ is unnecessary in your project, comment corresponding ‘import’ line in ‘rl_utils.py’ file. b. or you try to find out why the absence of class ‘run_experiment’, most likely due to the installation of ‘dopamine’.

0reactions
Tracy-gitcommented, Jul 14, 2021

@Q-ihang your methed solve my problem thks

Read more comments on GitHub >

github_iconTop Results From Across the Web

No module named 'tensorflow.compat.v2' · Issue #26546
but I am getting this error. ModuleNotFoundError: No module named 'tensorflow.compat' then i wrote this command "pip install tensorflow.compat" ...
Read more >
python - No modules named 'tensorflow.compat.v2' on Colab
The tf. compat. v2 module was added in 1.14 . Upgrade to 1.14 , 1.15 , or 2.0 and this will work fine....
Read more >
Module: tf.compat | TensorFlow v2.11.0
v2 submodules provide a complete copy of both the v1 and v2 APIs for backwards and forwards compatibility across TensorFlow versions 1.x and...
Read more >
no module tensorflow.compat.v2 Code Example
ImportError: No module named tensorflow ; 1. #if you are using bert its only comaptible with python 2.7/pip2 ; 2. #and tensorflow 1.15.0...
Read more >
Unresolved reference for tensorflow.compat, tensorflow.data
Pycharm highlights the compat in import tensorflow.compat.v1 as v1 as an error, “No module named compat” and Code Completion which depends on it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found