ModuleNotFoundError: No module named 'tensorflow.contrib' - google-colaboratory

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

Related

How to import deep_sort module in google colab?

I try to import the deep_srort module in my colab. But it shows me the following:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-9-b784ee656306> in <module>()
----> 1 from deep_sort import preprocessing
2 from deep_sort import nn_matching
3 from deep_sort.detection import Detection
4 from deep_sort.tracker import Tracker
5 from tools import generate_detections as gdet
ModuleNotFoundError: No module named 'deep_sort'
Cloning the repo and installing the requirements solved the problem for me:
!git clone https://github.com/theAIGuysCode/yolov4-deepsort
%cd yolov4-deepsort/
!pip install -r requirements-gpu.txt

Huggingface transformers error: "from transformers.trainer_utils import get_last_checkpoint,is_main_process"

I am using Google Colab and trying to use transformers. first, I installed trasnformers using pip, and it installed successfully but I was still unable to import the following functions
from transformers.trainer_utils import get_last_checkpoint,is_main_process
Next I tried to install Transformers from source in a virtual environment. I installed it successfully, but was still getting the same error as shown below.
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-53-d42272f1d6ac> in <module>()
----> 1 from transformers.trainer_utils import get_last_checkpoint,is_main_process
ModuleNotFoundError: No module named 'transformers.trainer_utils'
From comments
The issue fixed after installing "master" version from source as shown
below
pip install git+github.com/huggingface/transformers

ModuleNotFoundError: No module named 'tensorflow_datasets'

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/

I want to use pandas2ri in JUPYTER but tzlocal issue?

Everytime I try to import the pandas2ri in jupyter, python interface:
from rpy2.robjects import pandas2ri
I get the following error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-28-cc52694d111a> in <module>()
----> 1 from rpy2.robjects import pandas2ri
/Users/sondosayyash/anaconda/lib/python3.6/site-packages/rpy2/robjects/pandas2ri.py in <module>()
21 import numpy
22 import pytz
---> 23 import tzlocal
24 import warnings
25
ModuleNotFoundError: No module named 'tzlocal'
I tried to use
from dateutil.tz import tzlocal
but that didn't seem to fix the issue.
I've already installed tzlocal and it is on my computer. When I import pandas2ri on ipython, there is no problem.. the problem only occurs when calling in the jupyter environment.
this is the message I get when I try to install tzlocal again:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020.
Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: tzlocal in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (1.5.1)
Requirement already satisfied: pytz in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from tzlocal) (2017.2)
I had a similar issue when running rpy2 in Jupyter. I did not have the package installed previously. I just installed the package and the error went away. You can try installing the package again to see if it helps resolve your issue.
pip install tzlocal
I must add that I am using Python 3.6.8 not 2.7
If using conda:
conda install tzlocal
worked.
I had a similar issue as yours. It turns out that my local lib did not have the tzlocal package. So I installed the package through Anaconda prompt:
pip install tzlocal
And the issue is gone.

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