ModuleNotFoundError: No module named 'tensorflow_datasets' - tensorflow

I try to run
import tensorflow_datasets as tfds
but got the following error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-46a8a2031c9c> in <module>
----> 1 import tensorflow_datasets as tfds
ModuleNotFoundError: No module named 'tensorflow_datasets'
I have the tensorflow_datasets results, below is a snippets of pip list
tensorboard 2.1.1
tensorflow 2.1.0
tensorflow-datasets 2.1.0
tensorflow-estimator 2.1.0
tensorflow-hub 0.7.0
tensorflow-metadata 0.21.1
I am running using Ubuntu 16.04 with Anaconda virtual environment. How should I resolve this issue?

Not an issue as jupyterlab does not pickup the virtual environment. We need to set according to the following: https://janakiev.com/blog/jupyter-virtual-envs/

Related

No module named 'tensorflow.keras.layers.experimental.preprocessing'

Below the code
import numpy as np
np.random.seed(0)
from sklearn import datasets
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format ='retina'
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import SGD
below the Error message
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\keras\__init__.py in <module>
2 try:
----> 3 from tensorflow.keras.layers.experimental.preprocessing import RandomRotation
4 except ImportError:
ModuleNotFoundError: No module named 'tensorflow.keras.layers.experimental.preprocessing'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-5-943507dd87a6> in <module>
6 get_ipython().run_line_magic('config', "InlineBackend.figure_format ='retina'")
7
----> 8 from keras.models import Sequential
9 from keras.layers import Dense
10 from keras.optimizers import SGD
~\Anaconda3\lib\site-packages\keras\__init__.py in <module>
4 except ImportError:
5 raise ImportError(
----> 6 'Keras requires TensorFlow 2.2 or higher. '
7 'Install TensorFlow via `pip install tensorflow`')
8
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow
Note:` I think, the main problem is Tensorflow version. I used somes command and that's are bellow,
conda create -n tf tensorflow
conda activate tf
and I also used the below command
conda create -n tf-gpu tensorflow-gpu
conda activate tf-gpu
But it don't works , Please help for solve the error.
you need to update the version of your TensorFlow. For me, 2.2.0 solved the problem. I also checked with the higher versions and worked ok.
pip install tensorflow==2.2.0
or
pip install tensorflow-gpu==2.2.0
You need update TensorFlow. You can try with
pip install tensorflow==2.0.0
or, if you use gpu version
pip install tensorflow-gpu==2.0.0
If doesn't solve your issue, you can also try with 2.2.0 version.
For more details, in this issue follow this answer

ModuleNotFoundError: No module named 'tensorflow.contrib'

I cannot use edward package on google cola.
I have the below error:
ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 import edward
4 frames
/usr/local/lib/python3.6/dist-packages/edward/models/dirichlet_process.py in ()
6
7 from edward.models.random_variable import RandomVariable
----> 8 from tensorflow.contrib.distributions import Distribution
9
10 try:
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.
Uninstalling current/latest version of tensorflow and installing version 1.14 resolved it for me. Looks like they removed tensorflow.contrib from tensorflow version >1.14.
!pip uninstall tensorflow
!pip install tensorflow==1.14

Module Not found error on Google Colaboratory

Getting a weird import error when running the following code.
! pip install --user --upgrade git+https://github.com/broadinstitute/keras-resnet
import keras
import keras_resnet
Basically, I'm trying to install keras_resnet for keras_retinanet on Google colab however I'm getting a not found error. Output is below. The installation completes but then the import fails. Tested it locally and it works only fails on Google Colaboratory.
Running setup.py install for keras-resnet ... - \ done
Successfully installed keras-resnet-0.0.8
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-25-4521fd3221d7> in <module>()
2 #os.chdir('keras-retinanet')
3 import keras
----> 4 import keras_resnet
5 #from keras-retinanet.keras_retinanet.models.resnet import custom_objects
6 #model = keras.models.load_model('/path/to/model.h5', custom_objects=custom_objects)
ModuleNotFoundError: No module named 'keras_resnet'
Try dropping the --user? This worked for me:
!pip install --upgrade git+https://github.com/broadinstitute/keras-resnet
import keras
import keras_resnet

Tensorflow CPU Version Installation Error

I am running Ubuntu by using Virtualbox on Windows10.
I installed Tensorflow CPU version in terminal using pip3 install --upgrade tensorflow as per instruction given in official site of Tensorflow. And when I tried to validate installation as import tenorflow as tf it showed following error:
Traceback (most recent call last):
File "<stdin>", line1, in <module>
ImportError: No module named tensorflow
What should I do, to fix this error?

Tensorflow error in Jupyter notebook

After having installed tensorflow on Ubuntu 16.0 on AWS,
by using :
conda install -c conda-forge tensorflow=1.2.1
When typing on terminal SSH :
ipython
import tensorflow as tf
tf.__version__
It returns 1.2.1 and everything is fine.
But, when this code is run on Jupyter Ipython notebook
launched from same python install (anaconda),
I got this error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-b6f7b46cc0dd> in <module>()
1 import tensorflow as tf
----> 2 tf.__version__
AttributeError: module 'tensorflow' has no attribute '__version__'
Don't understand how this error can come over since the python distribution
is the same.
Is there a way to check the install of Tensorflow ?
EDIT:
This post https://github.com/tensorflow/tensorflow/issues/3369
shows it might be related to sudo access to some folders.... when installed.
TBD